source: FOIAVistA/trunk/r/MENTAL_HEALTH-YS-RUCL-YI-YT/YSGAFUTL.m@ 1429

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

initial load of FOIAVistA 6/30/08 version

File size: 5.9 KB
Line 
1YSGAFUTL ;DALCIOFO/MJD-GAF CLEANUP UTILITY ROUTINE ;02/17/99
2 ;;5.01;MENTAL HEALTH;**49**;Dec 30, 1994
3 ;
4 ;This routine will perform the following:
5 ;
6 ;1) Identify the DIAGNOSTIC RESULTS - MENTAL HEALTH file (#627.8)
7 ;records that contain no AXIS 5 (#65) data or DIAGNOSIS BY (#.04)
8 ;data after the installation of patch YS*5.01*43. Only records with
9 ;a DATE/TIME OF DIAGNOSIS field (#.04) containing a fiscal year 1998
10 ;or fiscal year 1999 date will be reviewed.
11 ;2) Delete these records if they contain no other related data.
12 ;3) Create a MAILMAN message that summarizes the status of the records.
13 ;4) Verify that the PATIENT TYPE (#66) is correct by
14 ;calling IN5^VADPT. If the patient type is incorrect, the routine
15 ;updates the field with the correct type (In-patient or Out-patient).
16 ;
17 ;NOTE: PLEASE EXECUTE THIS ROUTINE BY CALLING LINE TAG "START^YSGAFUTL"
18 ;
19 Q
20START ;Set up task
21 ;
22 I '$D(DUZ) D Q
23 .W !!,$C(7),"ERROR: DUZ is not defined. Use ^XUP or ask your "
24 .W !,"IRM why you don't have a DUZ variable defined.",!!
25 .D CLNUP
26 S YSGFDATE="",YSSTD=2971001,YSSPD=2990930
27 S ZTRTN="EN^YSGAFUTL"
28 ;
29 ;VARIABLES TO BE SAVED IN ZTSAVE
30 S ZTSAVE("*")=""
31 S ZTDESC="MENTAL HEALTH - YS GAF UTILITY"
32 S ZTIO=""
33 D ^%ZTLOAD
34 I '$D(ZTSK) QUIT ;-->
35 W !!,"The Mental Health GAF Utility has been Tasked, job# ",ZTSK,"...",!
36 Q
37 ;
38EN ; Main subroutine
39 I $D(ZTQUEUED) S ZTREQ="@" K ZTSK
40 K ^TMP("YSGAFUTL",$J),^TMP("YSGMM",$J)
41 ; Date range will be from 10-01-97 to TODAY
42 S:$G(U)="" U="^"
43 S YSAOF=""
44 S (YSIEN,YSPIEN,YSPATID,YSAPATID,YSADT,YSPTC,YSDDC,YSPTO,YSERC)=0
45 S (YSTOT,YSGDC,YSNMC,YSDEL)=0
46 F YSI="FY98","FY99" D
47 .F YSJ="I","O" S YSTOT(YSI,YSJ)=0
48 F S YSIEN=$O(^YSD(627.8,YSIEN)) Q:YSIEN=""!('YSIEN) D
49 .S YSO=$G(^YSD(627.8,YSIEN,0)),YSYEAR="FY99"
50 .S YSPATID=$P(YSO,U,2) ; Patient ID
51 .S YSGAFDT=$P(YSO,U,3) ; Date/time of diagnosis
52 .S MDFLG=0
53 .I YSGAFDT="" D Q ; Count the number of records missing
54 ..S MDFLG=1 ; the date/time of diagnosis and delete
55 ..D DELCHK ; if no other data is found.
56 ..S YSDDC=YSDDC+1 ; Count both deleted/non-deleted in YSDDC
57 .S YSGFDATE=$P($P(YSO,U,3),".",1)
58 .I (YSGFDATE>(YSSTD-1))&(YSGFDATE<(YSSPD+1)) D
59 ..S YSTOT=YSTOT+1 ; Count total records found in this date range
60 ..S:YSGFDATE<2981001 YSYEAR="FY98"
61 ..S YSTOT(YSYEAR)=$G(YSTOT(YSYEAR))+1
62 ..S YSP=$G(^YSD(627.8,YSIEN,60)),YSPATYPE=$P(YSP,U,4)
63 ..; Re-evaulate patient type indicator (In/Out patient)
64 ..S DFN=YSPATID
65 ..S VAIP("D")=YSGAFDT
66 ..D IN5^VADPT
67 ..S YSSTAT=$S(VAIP(1):"I",1:"O")
68 ..; If patient types don't match, update the record
69 ..I YSPATYPE'=YSSTAT D
70 ...S YSPATYPE=YSSTAT
71 ...S YSPTC=YSPTC+1
72 ...S DIE="^YSD(627.8,",DA=YSIEN
73 ...S DR="66////"_YSSTAT
74 ...L +^YSD(627.8,DA):0
75 ...D ^DIE
76 ...L -^YSD(627.8,DA)
77 ..S YSTOT(YSYEAR,YSPATYPE)=$G(YSTOT(YSYEAR,YSPATYPE))+1
78 ..; Check for missing data (GAF or Provider)
79 ..S YSAX5=$P(YSP,U,3),YSPROV=$P(YSO,U,4)
80 ..I YSAX5=""!(YSPROV="") D
81 ...; Verify that record is not entered in error
82 ...S YSEFLG=0
83 ...I $D(^YSD(627.8,YSIEN,80)) D
84 ....S YSERN=0
85 ....F S YSERN=$O(^YSD(627.8,YSIEN,80,YSERN)) Q:YSERN'>0!(YSEFLG) D
86 .....I $G(^YSD(627.8,YSIEN,80,YSERN,0))["Error" S YSEFLG=1 Q
87 ...I YSEFLG S YSERC=YSERC+1 Q
88 ...; If outpatient, update totals and quit
89 ...I YSPATYPE="O" D Q
90 ....D DELCHK Q:FLGDEL
91 ....S YSPTO=YSPTO+1
92 ...D DELCHK Q:FLGDEL
93 ...S YSNMC=YSNMC+1 ; Inpatient
94 ..E S YSGDC=YSGDC+1 ; Currently contains both GAF and Provider
95 D DELREC,TOTREP
96 D MAILIT,CLNUP
97 Q
98DELREC ; Delete records
99 Q:'$D(^TMP("YSGAFUTL",$J))
100 S DIK="^YSD(627.8,",DA=""
101 F S DA=$O(^TMP("YSGAFUTL",$J,DA)) Q:DA="" D ^DIK
102 Q
103TOTREP ;Write totals to ^TMP
104 S YSLN=0
105 S YSSUBT=YSGDC+YSERC+YSPTO+YSNMC+YSDEL
106 S XTMP="GAF CLEANUP UTILITY TOTALS" D YSLN,SPC
107 S XTMP="Total GAF Records:" D YSLN,SPC
108 F YSI="FY98","FY99" D
109 .F YSJ="I","O" D
110 ..S XTMP=$J(+$G(YSTOT(YSI,YSJ)),8)_" "
111 ..S XTMP=XTMP_$S(YSJ="I":"In",1:"Out")_"-patient" D YSLN
112 .D DSH
113 .S XTMP=$J(+$G(YSTOT(YSI)),8)_" Total "_YSI_" GAF Records" D YSLN,DSH
114 S XTMP=$J(YSTOT,8)_" Total GAF Records for Fiscal Years 98 and 99"
115 D YSLN
116 F YSI=1:1:2 D DSH
117 D SPC
118 S XTMP="GAF Record Summary:" D YSLN,SPC
119 S XTMP=$J(YSGDC,8)_" Record(s) currently contain Provider "
120 S XTMP=XTMP_"and GAF data" D YSLN
121 S XTMP=$J(YSERC,8)_" Record(s) entered in error" D YSLN
122 S XTMP=$J(YSPTO,8)_" Outpatient record(s) missing data" D YSLN
123 S XTMP=$J(YSNMC,8)_" Inpatient record(s) missing data" D YSLN
124 S XTMP=$J(YSDEL,8)_" Record(s) deleted due to incomplete data"
125 D YSLN,DSH
126 S XTMP=$J(YSSUBT,8)_" Total GAF Records"
127 D YSLN,DSH,DSH,SPC
128 S XTMP=$J((YSTOT-YSSUBT),8)_" Difference" D YSLN,SPC
129 I YSPTC D
130 .S XTMP="The PATIENT TYPE field (#66) was updated for "_YSPTC
131 .S XTMP=XTMP_" GAF record(s)." D YSLN
132 I YSDDC D
133 .S XTMP="DATE/TIME OF DIAGNOSIS field (#.04) was missing for "_YSDDC
134 .S XTMP=XTMP_" GAF record(s)." D YSLN
135 Q
136SPC ;
137 S XTMP=" " D YSLN
138 Q
139DSH ;
140 S XTMP="--------" D YSLN
141 Q
142MAILIT ; Mail totals
143 S DTIME=600
144 S XMSUB="GAF Cleanup Utility"
145 S XMTEXT="^TMP(""YSGMM"",$J,"
146 S XMY(DUZ)=""
147 S XMY("YOUNG,TIM@ISC-DALLAS.VA.GOV")=""
148 S XMY("DEVLIN,MARK@ISC-DALLAS.VA.GOV")=""
149 S XMDUZ="AUTOMATED MESSAGE"
150 D ^XMD
151 Q
152YSLN ;Store to ^TMP for MAILMAN message
153 S YSLN=YSLN+1
154 S ^TMP("YSGMM",$J,YSLN)=XTMP
155 Q
156DELCHK ;Check records and flag for deletion if necessary
157 S (FLGDEL,FLGDATA)=0
158 F I=1,5,80 D Q:FLGDATA
159 .S:$D(^YSD(627.8,YSIEN,I)) FLGDATA=1
160 I $D(^YSD(627.8,YSIEN,60)) D Q:FLGDATA
161 .I $P(^YSD(627.8,YSIEN,60),"^")'="" S FLGDATA=1 Q
162 .I $P(^YSD(627.8,YSIEN,60),"^",2)'="" S FLGDATA=1
163 ;No data was found so flag it for deletion and update counter
164 S ^TMP("YSGAFUTL",$J,YSIEN)="",FLGDEL=1
165 S:'MDFLG YSDEL=YSDEL+1
166 Q
167CLNUP ;Clean up variables
168 K X,Y,YSADT,YSAOF,YSAPATID,YSGAFDT
169 K YSGFDATE,YSIEN,YSO,YSPATID,YSPIEN,YSO,YSSPD,YSSTD,XTMP,VAIP
170 K YSAX5,YSDDC,YSDEL,YSEFLG,YSERC,YSERN,YSGDC,YSLN,YSNMC,YSP,YSSUBT
171 K YSPATYPE,YSPROV,YSPTC,YSPTO,YSSTAT,YSTOT
172 K YSYEAR,YSI,YSJ,XMDUZ,XCNP,XMZ,VAERR,FLGDATA,FLGDEL,DFN
173 K MDFLG,^TMP("YSGAFUTL",$J),^TMP("YSGMM",$J)
174 Q
Note: See TracBrowser for help on using the repository browser.