source: WorldVistAEHR/trunk/r/MENTAL_HEALTH-YS-RUCL-YI-YT/YSDSS.m@ 1279

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

initial load of WorldVistAEHR

File size: 4.6 KB
Line 
1YSDSS ;DALCIOFO/MJD-MENTAL HEALTH DSS EXTRACT ;05/19/99
2 ;;5.01;MENTAL HEALTH;**56**;Dec 30, 1994
3 Q
4 ;
5UPD(YSFILE,YSFRN,YSYRMO,YSEXTN,YSSITE,YSSD,YSEND,YSERR) ;parameter list
6 ;
7 ; YSFILE - MENTAL HEALTH EXTRACT file (#727.812) - constant
8 ; YSFRN - Last IEN of the MENTAL HEALTH EXTRACT file (#727.812)
9 ; YSYRMO - YearMonth of the extract to which this record belongs
10 ; YSEXTN - Identifies the specific extract to which this record belongs
11 ; YSSITE - Facility number
12 ; YSSD - Start date for extract
13 ; YSEND - End date for extract
14 ; YSERR - for return of "1", if error condition; otherwise return "0";
15 ; passed by reference; if any parameter missing or incorrect
16 ; format, then return "1"
17 ;
18 ;
19 ; Check for DSS MH TESTS file (#727.5)
20 I '$D(^ECX(727.5,0)) S YSERR=1 Q
21 ; Check for YTAPI2 routine
22 S X="YTAPI2" X ^%ZOSF("TEST") I '$T S YSERR=1 Q
23 ;
24 D PT
25 D ASI
26 D GAF
27 Q
28 ;
29PT ; Retrieve the PSYCH INSTRUMENT PATIENT file (#601.2) data
30 N YSD,YSD2,YSDFN,YSTSTN
31 S YSDFN=0
32 F S YSDFN=$O(^YTD(601.2,YSDFN)) Q:YSDFN=""!('YSDFN) D
33 .Q:$$TEST(YSDFN)
34 . S YSD=0
35 . F S YSD=$O(^YTD(601.2,YSDFN,1,YSD)) Q:'YSD D
36 .. S YSTSTN=$P($G(^YTT(601,+YSD,0)),U)
37 .. Q:YSTSTN=""
38 .. S YSD2=0
39 .. F S YSD2=$O(^YTD(601.2,YSDFN,1,YSD,1,YSD2)) Q:'YSD2 D
40 ... Q:(YSD2<(YSSD)) Q:(YSD2>(YSEND+1))
41 ... S YSDET=0 D CHKT
42 ... I YSDET D
43 .... S YS("DFN")=YSDFN
44 .... S YS("CODE")=YSTSTN
45 .... S YS("ADATE")=$$FMTE^XLFDT(YSD2,"2DZ")
46 .... D SCOREIT^YTAPI2(.YSDATA,.YS)
47 .... S YSPRV=$P(^YTD(601.2,YSDFN,1,YSD,1,YSD2,0),U,3)
48 .... S YSSCOR=""
49 .... S YSS=5
50 .... F S YSS=$O(YSDATA(YSS)) Q:YSS'>0 D
51 ..... S YSSCNUM=$P(YSDATA(YSS),U)
52 ..... S YSSCNAM=$P(YSDATA(YSS),U,2)
53 ..... S YSSCSC=$P(YSDATA(YSS),U,3)
54 ..... D CR
55 ..... Q
56 ... I 'YSDET D
57 .... S (YSPRV,YSSCNUM,YSSCNAM,YSSCOR,YSSCSC)=""
58 .... D CR
59 .... Q
60 ... Q
61 .. Q
62 .Q
63 Q
64 ;
65CHKT ;
66 N YS,YSACT,YSINACT
67 S (YS,YSDET)=0,(YSACT,YSINACT)=""
68 Q:'$D(^ECX(727.5,"B",YSTSTN))
69 S YS=$O(^ECX(727.5,"B",YSTSTN,YS))
70 Q:'$D(^ECX(727.5,YS,0))
71 S YSACT=$O(^ECX(727.5,"AC",YS,9999999),-1)
72 I $D(^ECX(727.5,"AX",YS)) S YSINACT=$O(^ECX(727.5,"AX",YS,9999999),-1)
73 Q:YSACT>YSD2
74 Q:YSINACT>YSACT
75 S YSDET=1
76 Q
77 ;
78CR ;Create a MENTAL HEALTH EXTRACT
79 S YSFRN=YSFRN+1
80 S ^ECX(YSFILE,YSFRN,0)=YSFRN_U_YSYRMO_U_YSEXTN_U_YSSITE_U_YSDFN
81 S $P(^ECX(YSFILE,YSFRN,0),U,9)=YSD2
82 S $P(^ECX(YSFILE,YSFRN,0),U,18)=YSPRV
83 S $P(^ECX(YSFILE,YSFRN,0),U,21)=YSTSTN
84 S $P(^ECX(YSFILE,YSFRN,0),U,22)=YSD
85 S $P(^ECX(YSFILE,YSFRN,0),U,23)=YSSCNUM
86 S $P(^ECX(YSFILE,YSFRN,0),U,24)=YSSCNAM
87 S $P(^ECX(YSFILE,YSFRN,0),U,25)=YSSCOR
88 S $P(^ECX(YSFILE,YSFRN,0),U,26)=YSSCSC
89 QUIT
90 ;
91ASI ; ASI
92 N YSDFN,YSIEN,YSASIDT
93 S YSTSTN="ASI"
94 S YSDFN=0
95 F S YSDFN=$O(^YSTX(604,"C",YSDFN)) Q:'YSDFN D
96 .Q:$$TEST(YSDFN)
97 . S YSIEN=0
98 . F S YSIEN=$O(^YSTX(604,"C",YSDFN,YSIEN)) Q:'YSIEN D
99 .. Q:'$D(^YSTX(604,YSIEN,0))
100 .. S YSASIDT=$P($P(^YSTX(604,YSIEN,0),"^",5),".",1)
101 .. I (YSASIDT>(YSSD-1))&(YSASIDT<(YSEND+1)) D
102 ... S YSDTOI=$P(^YSTX(604,YSIEN,0),U,5)
103 ... S YSPRV=$P(^YSTX(604,YSIEN,0),U,9)
104 ... S YS("DFN")=YSDFN
105 ... S YS("CODE")="ASI"
106 ... S YSCLAS=$P(^YSTX(604,YSIEN,0),U,4)
107 ... S YSSPEC=$P(^YSTX(604,YSIEN,0),U,11)
108 ... S YS("ADATE")=$$FMTE^XLFDT(YSASIDT,"2DZ")
109 ... D SCOREIT^YTAPI2(.YSDATA,.YS)
110 ... F YSS=6:1 Q:YSS>12 D CRASI
111 ... Q
112 .. Q
113 . Q
114 Q
115 ;
116CRASI ;
117 S YSFRN=YSFRN+1
118 S YSSCNUM=$P(YSDATA(YSS),U)
119 S YSSCNAM=$P(YSDATA(YSS),U,2)
120 S YSSCSC=$TR($P(YSDATA(YSS),U,4)," ")
121 S ^ECX(YSFILE,YSFRN,0)=YSFRN_U_YSYRMO_U_YSEXTN_U_YSSITE_U_YSDFN
122 S $P(^ECX(YSFILE,YSFRN,0),U,9)=YSDTOI
123 S $P(^ECX(YSFILE,YSFRN,0),U,18)=YSPRV
124 S $P(^ECX(YSFILE,YSFRN,0),U,21)=YSTSTN
125 S $P(^ECX(YSFILE,YSFRN,0),U,23)=YSSCNUM
126 S $P(^ECX(YSFILE,YSFRN,0),U,24)=YSSCNAM
127 S $P(^ECX(YSFILE,YSFRN,0),U,26)=YSSCSC
128 S ^ECX(YSFILE,YSFRN,1)=""
129 S $P(^ECX(YSFILE,YSFRN,1),U,5)=YSCLAS
130 S $P(^ECX(YSFILE,YSFRN,1),U,6)=YSSPEC
131 QUIT
132 ;
133GAF ; GAF
134 N YSIEN
135 S YSIEN=0
136 F S YSIEN=$O(^YSD(627.8,YSIEN)) Q:YSIEN=""!('YSIEN) D
137 . Q:'$D(^YSD(627.8,YSIEN,0))
138 . S YSGFDATE=$P($P(^YSD(627.8,YSIEN,0),"^",3),".",1)
139 . I (YSGFDATE>(YSSD-1))&(YSGFDATE<(YSEND+1)) D
140 .. I $P($G(^YSD(627.8,YSIEN,60)),U,3)="" Q
141 .. S YSDFN=$P(^YSD(627.8,YSIEN,0),U,2)
142 .. Q:$$TEST(YSDFN)
143 .. S YSFRN=YSFRN+1
144 .. S YSPRV=$P(^YSD(627.8,YSIEN,0),U,4)
145 .. S YSTSTN="GAF"
146 .. S YSSCOR=$P($G(^YSD(627.8,YSIEN,60)),U,3)
147 .. S ^ECX(YSFILE,YSFRN,0)=YSFRN_U_YSYRMO_U_YSEXTN_U_YSSITE_U_YSDFN
148 .. S $P(^ECX(YSFILE,YSFRN,0),U,9)=YSGFDATE
149 .. S $P(^ECX(YSFILE,YSFRN,0),U,18)=YSPRV
150 .. S $P(^ECX(YSFILE,YSFRN,0),U,21)=YSTSTN
151 .. S $P(^ECX(YSFILE,YSFRN,0),U,25)=YSSCOR
152 .. Q
153 . Q
154 QUIT
155 ;
156TEST(YSDFN) ;is this a test patient?
157 N ARR,SSN
158 S DA=YSDFN,DIC="^DPT(",DIQ(0)="I",DR=".09",DIQ="ARR"
159 D EN^DIQ1
160 S SSN=ARR(2,YSDFN,.09,"I")
161 I $E(SSN,1,5)="00000" Q 1
162 Q 0
Note: See TracBrowser for help on using the repository browser.