source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SDSCOMP.m@ 1147

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

initial load of WorldVistAEHR

File size: 8.8 KB
Line 
1SDSCOMP ;ALB/JAM/RBS - ASCD Compile list of encounters for Service Connection Review ; 3/12/07 4:36pm
2 ;;5.3;Scheduling;**495**;Aug 13, 1993;Build 50
3 ;;MODIFIED FOR NATIONAL RELEASE from a Class III software product
4 ;;known as Service Connected Automated Monitoring (SCAM).
5 ;
6 ; Routine should be called at specified tags only.
7 Q
8 ;
9AUTODT ; Called by option "SDSC NIGHTLY COMPILE"
10 ; - Compile ASCD Encounters on a Nightly Basis
11 ; (Rated Disabilities/ICDs for Prior Day Encounters)
12 ;
13 N SDSCTDT,SDEDT,DIC,DA
14 ; nightly compile is for previous day only
15 S SDSCTDT=$$FMADD^XLFDT(DT,-1)
16 ; Set variable 'SDEDT' (loop end point) to same date
17 S SDEDT=SDSCTDT
18 ; Setup list of service connected eligibility codes.
19 D ELIG
20 G TASK1
21 ;
22GETDATE ; Entry point for edit or report - Get START and END dates
23 S SDSCBDT=$O(^SDSC(409.48,"AE",""))\1,SDSCEDT=DT
24 ; If no records currently available, display message.
25 I SDSCBDT=0 D EN^DDIOL("NO RECORDS ON FILE - RUN COMPILE",,"!!?10") HANG 3 S (SDSCTDT,SDEDT)="" Q
26 ;
27GETDATE1 ; Entry point for SDSC COMPILE option - Get START and END dates
28 ; Output:
29 ; Set var 'SDSCTDT' (loop start point) to a user selected date.
30 N DIR,X,Y,X1,X2
31 S DIR(0)="DA^"_SDSCBDT_":"_DT_":EX"
32 S DIR("A")="Please enter START date: "
33 ;S DIR("B")=$$FMTE^XLFDT(SDSCBDT,"1Z")
34 S DIR("?")="This START date cannot precede "_$$FMTE^XLFDT(SDSCBDT,"1Z")
35 ;
36 ; This check works for the "SDSC COMPILE" only.
37 ; - Compile does not setup SDSCEDT var
38 I SDSCBDT]"",SDSCEDT']"" D
39 . S DIR("B")=$$FMTE^XLFDT(SDSCBDT,"1Z")
40 . S DIR("?")="This START date cannot precede the default SDSC SITE PARAMETER days"
41 ;
42 D ^DIR
43 I $D(DTOUT)!$D(DUOUT) S (SDSCTDT,SDEDT)="" Q
44 S:Y>0 SDSCTDT=Y
45 ; check if start date has changed
46 I SDSCTDT'=SDSCBDT S SDSCBDT=SDSCTDT
47 ; Set variable 'SDEDT' (loop end point) to a user selected date.
48 K DIR
49 S DIR(0)="DA^"_SDSCBDT_":"_DT_":EX"
50 S DIR("A")="Please enter END date: "
51 S DIR("B")=$$FMTE^XLFDT($S(SDSCEDT]"":SDSCEDT,1:DT),"1Z")
52 S DIR("?")="This END date cannot precede the START date or exceed today's date"
53 D ^DIR
54 I $D(DTOUT)!$D(DUOUT) S (SDSCTDT,SDEDT)="" Q
55 S:Y>0 SDEDT=Y
56 Q
57 ;
58ELIG ; Compile list of service connected eligibility codes.
59 N I,J
60 K SDLIST
61 ; loop "D" x-ref of ELIGIBILITY CODE (#8) file
62 ; Entries 1 and 3 are the service connected entries in this file.
63 F I=1,3 S J=0 F S J=$O(^DIC(8,"D",I,J)) Q:'J S SDLIST(J)=""
64 Q
65 ;
66COMPILE ; Called by option "SDSC COMPILE"
67 ; - Compile ASCD Encounters by Date Range
68 ; (Rated Disabilities/ICDs for Encounters)
69 N DIR,X,Y,SDSCBDT,SDSCEDT,ZTIO,ZTDESC,ZTRTN,ZTSAVE
70 N SDSCITE,SDSCDAY
71 D HOME^%ZIS
72 ; Get start and end date for compile.
73 S (SDSCBDT,SDSCEDT,SDSCDAY)=""
74 S SDSCITE=$P($$SITE^VASITE(),U,1)
75 S SDSCDAY=$$GET^XPAR((+SDSCITE)_";DIC(4,","SDSC SITE PARAMETER")
76 ; set default start date based on site parameter (30 days max)
77 I SDSCDAY="" S SDSCDAY=30
78 S SDSCBDT=$$FMADD^XLFDT(DT,-SDSCDAY)
79 ;
80 D GETDATE1 I SDSCTDT="" G END
81 ; Setup list of service connected eligibility codes.
82 D ELIG
83 ; Ask user if compile should be in background and handle queuing if requested.
84 K DIR
85 S DIR(0)="YA",DIR("B")="YES"
86 S DIR("A")="Do you wish to schedule the compile? "
87 S DIR("?")="Enter 'YES' to schedule compile using TaskMan or 'NO' to compile immediately."
88 D ^DIR
89 I $D(DTOUT)!$D(DUOUT) D EN^DDIOL("<Compile Aborted> ",,"!!?10") G END
90 I Y D G END
91 . S ZTIO="NULL",ZTDESC="COMPARE RATED DISABILITY/ICDs PER ENCOUNTER (COMPILE)",ZTRTN="TASK^SDSCOMP",ZTSAVE("*")=""
92 . D ^%ZTLOAD
93 . I $G(ZTSK)]"" D EN^DDIOL("Extract's TaskMan ID is "_ZTSK,"","!!?10")
94 . K ZTSK
95 . Q
96 D EN^DDIOL("Comparing Rated Disabilities and Diagnosis Code per Encounter ...",,"!!?10")
97 ;
98TASK ; Start compile (one-time compile - remove from queue when complete)
99 D OPT
100 I $D(ZTQUEUED) S ZTREQ="@"
101 G END
102 ;
103TASK1 ; Start compile (scheduled compile - don't remove from queue)
104 D OPT
105 G END
106 ;
107OPT ; Loop through all outpatient encounters for the specified dates.
108 N SDSCTOT,SDSCSVC,SDSCNSC,SDSCBAD,SDSCNCT,SDSCEXS,SDSCNDX,SDSCNBL
109 N SDSCMAP1,SDSCMAP2,SDSCINS,SDOEDT,SDOE
110 S (SDSCTOT,SDSCSVC,SDSCNSC,SDSCBAD,SDSCNCT,SDSCEXS,SDSCNDX,SDSCNBL,SDSCMAP1,SDSCMAP2,SDSCINS)=0
111 S SDOEDT=SDSCTDT F S SDOEDT=$O(^SCE("B",SDOEDT)) Q:(SDOEDT\1)>SDEDT Q:SDOEDT="" D
112 . S SDOE=0 F S SDOE=$O(^SCE("B",SDOEDT,SDOE)) Q:'SDOE D OPT1
113 . Q
114 ;
115 ; Check for newly identified insurance
116 D EN^SDSCINS(.SDSCINS,.SDSCSVC)
117 ;
118 ; Send mail message with counts of records
119 D MMSG
120 ;
121 ; Check for encounters in ASCD that were deleted from (#409.68)
122 D EN^SDSCPRG
123 Q
124 ;
125OPT1 ; Check the service connected info for one encounter.
126 N SDOEDAT,SDEC,SDPAT,SDCLIN,SDCST,SDV0,SDFILEOK,SDPRV,SDOSC
127 S SDSCTOT=SDSCTOT+1
128 ; If this encounter has already been compiled for review, quit.
129 I $D(^SDSC(409.48,SDOE,0)) S SDSCEXS=SDSCEXS+1 Q
130 ; Get encounter data. If no encounter data, quit.
131 ; Replace all ^SCE calls with new variable.
132 S SDOEDAT=$$GETOE^SDOE(SDOE)
133 I SDOEDAT="" S SDSCBAD=SDSCBAD+1 Q
134 ; if child encounter, reduce count and quit
135 I $P(SDOEDAT,U,6) S SDSCTOT=SDSCTOT-1 Q
136 ; if not Check-out, quit
137 I $P(SDOEDAT,U,12)'=2 S SDSCNBL=SDSCNBL+1 Q
138 ; Get eligibility. If no eligibility, quit.
139 S SDEC=$P(SDOEDAT,U,13) I SDEC="" S SDSCBAD=SDSCBAD+1 Q
140 ; If eligibility is not service connected, quit.
141 I '$D(SDLIST(SDEC)) S SDSCNSC=SDSCNSC+1 Q
142 ; Get patient. If no patient, quit.
143 S SDPAT=$P(SDOEDAT,U,2) I SDPAT="" S SDSCBAD=SDSCBAD+1 Q
144 ; Checks for clinic and stop code.
145 ; Get clinic. If no clinic, quit.
146 S SDCLIN=$P(SDOEDAT,U,4) I SDCLIN="" S SDSCBAD=SDSCBAD+1 Q
147 ; Get clinic stop code. If no clinic stop code, quit.
148 S SDCST=$P(SDOEDAT,U,3) I SDCST="" S SDSCBAD=SDSCBAD+1 Q
149 ; If clinic is non-count, quit.
150 I $$NCTCL^SDSCUTL(SDCLIN) S SDSCNCT=SDSCNCT+1 Q
151 ; If encounter is non-billable for first and third party, quit.
152 I $$NBFP^SDSCUTL(SDOE),$$NBTP^SDSCUTL(SDOE) S SDSCNBL=SDSCNBL+1 Q
153 ; Get visit file entry. If no visit, quit.
154 S SDV0=$P(SDOEDAT,U,5) I SDV0="" S SDSCBAD=SDSCBAD+1 Q
155 S SDOSC=$$GET1^DIQ(9000010,SDV0_",",80001,"I")
156 I SDOSC="" S SDSCNBL=SDSCNBL+1 Q
157 ; Get and evaluate all ICD9 entries for the specified visit.
158 S SDFILEOK=$$SC^SDSCAPI(SDPAT,,SDOE)
159 ;no ICDs were found for this encounter SDFILEOK=""
160 I SDFILEOK="" S SDSCNDX=SDSCNDX+1 Q
161 ;checks if ICD match found
162 I +SDFILEOK D
163 .I '$P(SDFILEOK,"^",4) S SDSCMAP1=SDSCMAP1+1 Q
164 .S SDSCMAP2=SDSCMAP2+1
165 I '+SDFILEOK S SDSCNSC=SDSCNSC+1
166 ; Get Primary Provider for the specified visit.
167 S SDPRV=$$PRIMVPRV^PXUTL1(SDV0) I SDPRV=0 S SDPRV=""
168 ; Store the encounter for later use.
169 S SDSCSVC=SDSCSVC+1
170 I $P(SDFILEOK,U,4) Q:$D(^SDSC(409.48,SDOE,0)) D STORE Q
171 I SDOSC'=$P(SDFILEOK,U) D STORE
172 Q
173 ;
174STORE ; Save the information for the found encounter.
175 N SDERR,SDIEN,SDSC
176 S SDIEN(1)=SDOE
177 S SDSC(409.48,"+1,",.01)=SDOE
178 S SDSC(409.48,"+1,",.04)=DT
179 S SDSC(409.48,"+1,",.07)=SDOEDT
180 S SDSC(409.48,"+1,",.08)=SDPRV
181 S SDSC(409.48,"+1,",.09)=$P(SDFILEOK,U,3)
182 S SDSC(409.48,"+1,",.11)=SDPAT
183 S SDSC(409.48,"+1,",.12)=$P(SDOEDAT,U,11)
184 S SDSC(409.48,"+1,",.05)="N"
185 S SDSC(409.48,"+1,",.13)=SDOSC
186 D UPDATE^DIE("","SDSC","SDIEN","SDERR")
187 Q
188 ;
189MMSG ; Send Mail Message
190 N SDCNT,SDTEXT,DIFROM,XMY,XMDUZ,XMTEXT,XMSUB,XMZ,XMDUN
191 S SDTEXT(1)="Date Range (Compile) - From: "_$$FMTE^XLFDT(SDSCTDT,1)_" Thru: "_$$FMTE^XLFDT(SDEDT,1)
192 S SDTEXT(2)="Date Range (Late Ins.) - "
193 I '$D(SDSCBDT),'$D(SDSCEDT) S SDTEXT(2)=SDTEXT(2)_"None"
194 E S SDTEXT(2)=SDTEXT(2)_"From: "_$$FMTE^XLFDT(SDSCBDT,1)_" Thru: "_$$FMTE^XLFDT(SDSCEDT,1)
195 S SDTEXT(3)=" "
196 S SDTEXT(4)="Number of encounters Service Connected (Compile) : "_$J(SDSCSVC-SDSCINS,7)
197 S SDTEXT(5)="Number of encounters Service Connected (Late Ins.) : "_$J(SDSCINS,7)
198 S SDTEXT(6)=" (Number SvcConn with a True Map) : "_$J(SDSCMAP1,7)
199 S SDTEXT(6.5)=" (Number SvcConn with a Partial Map) : "_$J(SDSCMAP2,7)
200 S SDTEXT(7)=" (Number SvcConn that don't Map to VBA) : "_$J(SDSCSVC-SDSCMAP1-SDSCMAP2,7)
201 S SDTEXT(8)="Number of encounters Not Service Connected : "_$J(SDSCNSC,7)
202 S SDTEXT(9)="Number of encounters that are Non-billable : "_$J(SDSCNBL,7)
203 S SDTEXT(10)="Number of encounters with Non-count Clinics : "_$J(SDSCNCT,7)
204 S SDTEXT(11)="Number of encounters with no diagnoses : "_$J(SDSCNDX,7)
205 S SDTEXT(12)="Number of encounters with other errors : "_$J(SDSCBAD,7)
206 S SDTEXT(13)="Number of encounters already evaluated : "_$J(SDSCEXS,7)
207 S SDTEXT(14)="---------------------------------------------------------------------------"
208 S SDTEXT(15)="Total Encounters Checked: "_$J(SDSCTOT,7)
209 S SDCNT=15
210 D AUDIT^SDSCINS(.SDTEXT,.SDCNT)
211 I $G(DUZ)="" S XMZ(.5)=""
212 S XMZ(DUZ)="",XMDUZ="ASCD Compile",XMY("G.SDSC NIGHTLY TALLY")=""
213 S XMTEXT="SDTEXT(",XMSUB="ASCD Compile Numbers"
214 D ^XMD
215 Q
216 ;
217END ; Clear all variables before exiting.
218 K SDSCTDT,SDEDT,SDOEX,SDRD,SDRDIEN,SDSCBDT,SDSCEDT,SDIEN,SDERR,SDSC
219 K SDVBA,SDVBAI,SDLIST,P,L,SDABRT,X,Y,DTOUT,DUOUT
220 Q
Note: See TracBrowser for help on using the repository browser.