source: FOIAVistA/trunk/r/MENTAL_HEALTH-YS-RUCL-YI-YT/YTQPXRM1.m@ 711

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

initial load of FOIAVistA 6/30/08 version

File size: 3.3 KB
Line 
1YTQPXRM1 ;ALB/ASF- MHA3 API FOR CLINICAL REMINDERS ; 3/13/07 1:43pm
2 ;;5.01;MENTAL HEALTH;**85**;Dec 30, 1994;Build 48
3 ;Reference to ^PXRMINDX(601.2, supported by DBIA #4114
4 ;Reference to ^PXRMINDX(601.84, supported by DBIA #??????
5 Q
6OCCUR(YSSUB,YS) ;occurances OF TESTS,GAF,ASI
7 ;Input:
8 ;YS("CODE"): Test code NUMBER from file 601.71 including "ASI","GAF"
9 ;YS("BEGIN"): inclusive date in %DT acceptable format (11/11/2011) to begin search [optional]
10 ;YS("END"): inclusive date in %DT acceptable format (11/11/2011) to end search [optional]
11 ;YS("LIMIT"): Last N administrations [optional]
12 ;Output
13 N G,YSLIMIT,YSJJ,YSSONE,S,R,N,YSN2,N4,I,II,DFN,YSCODE,YSCODEN,YSADATE,YSSCALE,YSBED,YSEND,YSAA,DAS,YSOCC,YSZN,YST,YSLM
14 N IFN,R1,R2,R3,SFN1,SFN2,YSBEG,YSCK,YSDFN,YSED,YSIFN,YSINUM,YSITEM,YSN2,YSNODE,YSPRIV,YSQT,YSR,YSSTAFF,YSTYPE,YSCODE,NI,YSID,%DT,X,Y,YS601
15 D PARSE(.YS)
16 S N=0
17 K ^TMP($J,YSSUB)
18 I YSCODE="ASI" D ASIOC Q ;-->out
19 I YSCODE="GAF" D GAFOC Q ;-->out
20 I '$D(^YTT(601.71,"B",YSCODE)) S ^TMP($J,YSSUB,1)="[ERROR]^BAD TEST CODE #" Q ;-->out
21 S NI=0
22PA S DFN=0
23 F S DFN=$O(^PXRMINDX(601.84,"IP",YSCODEN,DFN)) Q:DFN'>0 S YSOCC=0 D
24 . S YSN2=YSEND+.0000001 F S YSN2=$O(^PXRMINDX(601.84,"IP",YSCODEN,DFN,YSN2),-1) Q:YSN2'>0!(YSN2<YSBEG) D
25 .. S DAS=0 F S DAS=$O(^PXRMINDX(601.84,"IP",YSCODEN,DFN,YSN2,DAS)) Q:DAS'>0 D
26 ... S YSOCC=YSOCC+1
27 ... Q:(YSOCC>YSLM)
28 ... S NI=NI+1
29 ... S ^TMP($J,YSSUB,DFN,YSOCC)=DAS_U_YSN2_U_YSCODEN_"^601.84"
30P0 S DFN=0,YS601=$O(^YTT(601,"B",YSCODE,0))
31 F S DFN=$O(^PXRMINDX(601.2,"IP",YS601,DFN)) Q:DFN'>0 S YS("DFN")=DFN D P1
32 S ^TMP($J,YSSUB)="[DATA]"_U_NI
33 Q
34P1 S YSOCC=$O(^TMP($J,YSSUB,DFN,99999),-1)
35 S YSN2=YSEND+.1 F S YSN2=$O(^PXRMINDX(601.2,"IP",YS601,DFN,YSN2),-1) Q:YSN2'>0!(YSN2<YSBEG) D
36 . S YSOCC=YSOCC+1
37 . Q:(YSOCC>YSLM)
38 . S NI=NI+1
39 . S ^TMP($J,YSSUB,DFN,YSOCC)=DFN_";1;"_YS601_";1;"_YSN2_U_YSN2_U_YS601_"^601.2"
40 Q
41PARSE(YS) ; -- array parsing
42 S DFN=$G(YS("DFN"))
43 S (YSCODEN,YSCODE)=$G(YS("CODE"))
44 S YSCODE=$P($G(^YTT(601.71,YSCODE,0),"ERROR"),U)
45 S YSADATE=$G(YS("ADATE")) S X=YSADATE,%DT="T" D ^%DT S YSADATE=Y
46 S YSSCALE=$G(YS("SCALE"))
47 S YSBEG=$G(YS("BEGIN")) S:YSBEG="" YSBEG="01/01/1970" S X=YSBEG,%DT="T" D ^%DT S YSBEG=Y
48 S YSEND=$G(YS("END")) S:YSEND="" YSEND="01/01/2099" S X=YSEND,%DT="T" D ^%DT S YSEND=Y
49 S YSLM=$G(YS("LIMIT"),1)
50 Q
51GAFOC ;all axis5 DXs in time frame
52 S YS601=$O(^YTT(601,"B","GAF",0))
53 S YST=YSEND+.0000001,NI=0
54 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
55 . S X=$P($G(^YSD(627.8,IFN,60)),U,3)
56 . Q:X=""
57 . S DFN=$P($G(^YSD(627.8,IFN,0)),U,2) Q:DFN'>0 ;bad dfn
58 . S YSOCC=$O(^TMP($J,YSSUB,DFN,999999),-1)+1
59 . Q:(YSOCC>YSLM)
60 . S NI=NI+1
61 . S ^TMP($J,YSSUB,DFN,YSOCC)=DFN_";1;"_YS601_";1;"_IFN_U_YST_U_YS601_"^627.8"
62 S ^TMP($J,YSSUB)="[DATA]"_U_NI
63 Q
64ASIOC ;
65 S YS601=$O(^YTT(601,"B","ASI",0))
66 S NI=0,DFN=0,YSID=YSEND+.01
67 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
68 . Q:'$D(^YSTX(604,IFN,.5)) ; no sig
69 . S G=$G(^YSTX(604,IFN,0))
70 . S DFN=$P(G,U,2) Q:DFN'>0 ;bad dfn
71 . S YSOCC=$O(^TMP($J,YSSUB,DFN,999999),-1)+1
72 . Q:(YSOCC>YSLM)
73 . S NI=NI+1
74 . S ^TMP($J,YSSUB,DFN,YSOCC)=DFN_";1;"_YS601_";1;"_IFN_U_$P(G,U,5)_U_YS601_"^604"
75 S ^TMP($J,YSSUB)="[DATA]"_U_NI
76 Q
Note: See TracBrowser for help on using the repository browser.