source: FOIAVistA/trunk/r/ZZREGIONAL-A1C-A5C-CRHD-RGED-RGUT-RGWB-RG/RGMTUT01.m@ 677

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

initial load of FOIAVistA 6/30/08 version

File size: 9.1 KB
Line 
1RGMTUT01 ;BIR/CML-MPI/PD Compile and Correct Data Validation Data for Local Sites ;08/12/02
2 ;;1.0;CLINICAL INFO RESOURCE NETWORK;**20,31,41**;30 Apr 99
3 ;
4 ;Reference to $$UPDATE^MPIFAPI supported by IA #2706
5 ;Reference to VAFCTFU supported by IA #2988
6 ;Reference to ^DPT( supported by IA #2070
7 ;Reference to ^DGCN(391.91,"APAT" supported by IA #2911
8 ;Reference to ^%ZTSCH("TASK" supported by IA #3520
9 ;
10EN1 ;Use this entry point to get only display diagnostics for development team
11 ;BYPASS=0 means prohibit times are enforced
12 ;SITEOPT=0 means CMOR, TF, and diagnostics are included in report
13 ;SITEOPT=1 means diagnostics are omitted from report (this is the report for the site)
14 ;SITEOPT=2 means only diagnostics are in report
15 ;
16 S BYPASS=0,SITEOPT=2 G BEGIN
17 ;
18EN2 ;Use this entry point from remote query
19 S BYPASS=1,SITEOPT=0 G BEGIN ; **41
20 ;
21EN3 ;Use this entry point for site menu option [RG NATIONAL ICN STATISTICS] to omit
22 ;diagnostic section from report
23 S BYPASS=0,SITEOPT=1 G BEGIN
24 ;
25BY ;use this call to bypass check to prohibit primetime run
26 S BYPASS=1,SITEOPT=2
27 ;
28BEGIN ;
29 S PRT=0,QFLG=0 K RGROU
30 I $D(^XTMP("RGMT","UT01","@@","COMPILE STARTED"))&('$D(^XTMP("RGMT","UT01","@@","COMPILE STOPPED"))) D I QFLG G QUIT
31 .;check running tasks to see if compile is running
32 .S TASK=0 F S TASK=$O(^%ZTSCH("TASK",TASK)) Q:'TASK D
33 ..S RGROU=$P(^%ZTSCH("TASK",TASK),"^",2)
34 ..I RGROU="RGMTSTAT" D
35 ...I TASK=$G(ZTSK) Q
36 ...S QFLG=1
37 ...I '$D(RGHLMQ) W !!,"The Stat Report is currently being compiled."
38 .I 'QFLG K ^XTMP("RGMT","UT01"),^XTMP("RGMT","REINDDT")
39 ;
40 I $D(RGHLMQ) G STARTQ
41 W !!,"This option provides the following statistics:"
42 W !?3,"1. Total patients assigned to each unique COORDINATING MASTER OF"
43 W !?3," RECORD (CMOR)."
44 W !?3,"2. Total patients shared with each unique entry in the TREATING"
45 W !?3," FACILITY LIST (#391.91) file."
46 W !?3,"3. Totals for national ICNs, local ICNs, and patients with no ICN."
47 I SITEOPT=1 G START
48 W !?3,"4. Total CMOR assignments missing a matching Treating Facility."
49 W !?3,"5. Total patients with NATIONAL ICN and missing local Treating Facility."
50 W !?3,"6. Total number of patients with duplicate entries in the TREATING"
51 W !?3," FACILITY LIST file (#391.91)."
52 W !?3,"7. Patient File xref problems for ""AICN"", ""AICNL"", and ""SSN""."
53 W !?3,"8. Total number of patients with a no ICN but have a CMOR assignment."
54 W !?3,"9. Total number of patients with a no ICN but have TF assignments."
55 W !?3,"10. Total number of patients with a local ICN but have remote TFs."
56 ;
57START ;
58 S QFLG=0
59 I '$D(^XTMP("RGMT","UT01","@@","COMPILE STARTED")) W !!,"No data is currently available." I SITEOPT=1 G QUIT
60 ;
61 W !!,"===> NOTE <==="
62 I SITEOPT=1 D
63 .W !,"This data is compiled by a remote process initiated from the MPI in Austin"
64 .W !,"on a regular basis for reporting purposes. It is not compiled by the local"
65 .W !,"site, however, the local site can view the last report that was compiled.",!
66 ;
67 I $D(^XTMP("RGMT","UT01","@@","COMPILE STOPPED")) D G:QFLG QUIT I PRT D ^RGMTUT03 G QUIT
68 .S PRT=0
69 .S LAST=^XTMP("RGMT","UT01","@@","COMPILE STOPPED")
70 .S LAST=$$FMTE^XLFDT(LAST)
71 .W !,"This data was last compiled on ",LAST,"."
72 .I SITEOPT=1 S PRT=1 Q
73 .S DIR(0)="Y",DIR("B")="YES",DIR("A")="Do you just want a reprint of that data"
74 .S DIR("?",1)="Enter:"
75 .S DIR("?",2)=" ""YES"" or <RET> to reprint current data and NOT recompile."
76 .S DIR("?",3)=" ""NO"" to recompile new data (this may take several hours)."
77 .S DIR("?")=" ""^"" to HALT."
78 .D ^DIR K DIR
79 .I Y="^" S QFLG=1 Q
80 .I +Y=1 S PRT=1 Q
81 ;
82STARTQ ;pick up here for queued job
83 D NOW^%DTC
84 ;
85 ;check to be sure stat report not being run during prime time
86 S TODAY=$$DOW^XLFDT($$NOW^XLFDT()) I TODAY="Saturday"!(TODAY="Sunday") S BYPASS=1
87 S QUIT=0
88 I 'BYPASS D I QUIT G QUIT
89 .S CHKTIME=$E($P(%,".",2),1,4)
90 .I CHKTIME>"0700"&(CHKTIME<"1700") S QUIT=1 I '$D(RGHLMQ) D
91 ..W !!,"<< STAT report cannot be compiled between 7:00am and 5:00pm! >>"
92 ;
93 I '$D(RGHLMQ) W !!,"Recompiling data..."
94 ;
95 S ^XTMP("RGMT",0)=$$FMADD^XLFDT(DT,30)_"^"_$$NOW^XLFDT_"^MPI/PD Maintenance Data"
96 K ^XTMP("RGMT","UT01"),^XTMP("RGMT","REINDDT") ; **41
97 S ^XTMP("RGMT","UT01","@@","COMPILE STARTED")=%
98 ;
99 D REIND^RGMTUT02
100 D CMOR,TF,TFCHK
101 ;
102 I 'PRT D
103 .D NOW^%DTC
104 .S ^XTMP("RGMT","UT01","@@","COMPILE STOPPED")=%
105 D ^RGMTUT03
106 ;
107QUIT ;
108 K %,BYPASS,CHKTIME,LAST,LOC,PRT,QFLG,QUIT,SITEOPT,TODAY,Y,RGROU,TASK
109 Q
110 ;
111CMOR ; Check "ACMOR" xref for:
112 ; - existence of a TF entry for the CMOR in the TF file #391.91
113 ; - existence of a TF for the local site (if not the CMOR)
114 ; - CMOR totals by site
115 ;
116 I '$D(RGHLMQ) D
117 .W !!,"Check #1 for:"
118 .W !,"- Patients missing Treating Facility entries for their CMOR."
119 .W !,"- Patients missing Treating Facility entries for their local site."
120 .W !,"- Unique CMOR totals."
121 ;
122 K ^XTMP("RGMT","UT01","CMOR")
123 K ^XTMP("RGMT","UT01","TOT CMOR MISS TF")
124 K ^XTMP("RGMT","UT01","TOT LOC SITE MISS TF")
125 K ^XTMP("RGMT","UT01","CMOR WITH NO ICN")
126 S (CNT,NOICN,TOTMISSC,TOTMISSL)=0
127 S SITESTA=$P($$SITE^VASITE(),"^",3),SITEDA=$P($$SITE^VASITE(),"^")
128 ;
129 S CMOR=0 F S CMOR=$O(^DPT("ACMOR",CMOR)) Q:'CMOR D
130 .I '$D(CMOR(CMOR)) S CMOR(CMOR)=0
131 .S DFN=0 F S DFN=$O(^DPT("ACMOR",CMOR,DFN)) Q:'DFN D
132 ..S CNT=CNT+1 I '$D(RGHLMQ) W:'(CNT#10000) "."
133 ..S ICN=$P($G(^DPT(DFN,"MPI")),"^")
134 ..I $E(ICN,1,3)=SITESTA Q
135 ..I ICN="" D Q
136 ...S NOICN=NOICN+1
137 ...I '$D(RGHLMQ) W !?3,"DFN #",DFN," has no ICN and a CMOR of ",$P($$NS^XUAF4(CMOR),"^")
138 ...S ^XTMP("RGMT","UT01","CMOR WITH NO ICN",DFN)=""
139 ...S LOC(991.03)="@" W $$UPDATE^MPIFAPI(DFN,"LOC")
140 ..S CMOR(CMOR)=CMOR(CMOR)+1
141 ..I '$D(^DGCN(391.91,"APAT",DFN,CMOR)) D
142 ...S TOTMISSC=TOTMISSC+1
143 ...S SSN=$P($G(^DPT(DFN,0)),"^",9)
144 ...S NAME=$P($G(^DPT(DFN,0)),"^")
145 ...S ^XTMP("RGMT","UT01","CMOR","ZZMISSC",CMOR,DFN)="DFN/"_DFN_"^NAME/"_NAME_"^SSN/"_SSN_"^ICN/"_ICN
146 ...D FILE^VAFCTFU(DFN,CMOR,1)
147 ..I SITEDA'=CMOR,'$D(^DGCN(391.91,"APAT",DFN,SITEDA)) D
148 ...S TOTMISSL=TOTMISSL+1
149 ...S SSN=$P($G(^DPT(DFN,0)),"^",9)
150 ...S NAME=$P($G(^DPT(DFN,0)),"^")
151 ...S ^XTMP("RGMT","UT01","CMOR","ZZMISSL",CMOR,DFN)="DFN/"_DFN_"^NAME/"_NAME_"^SSN/"_SSN_"^ICN/"_ICN
152 ...D FILE^VAFCTFU(DFN,SITEDA,1)
153 ;
154 S CMOR=0 F S CMOR=$O(CMOR(CMOR)) Q:'CMOR D
155 .S CMORNM=$P($$NS^XUAF4(CMOR),"^"),CMORSTA=$P($$NS^XUAF4(CMOR),"^",2) Q:CMORSTA=""
156 .S ^XTMP("RGMT","UT01","CMOR",CMORNM,CMORSTA)=CMOR(CMOR)
157 S ^XTMP("RGMT","UT01","TOT CMOR MISS TF")=TOTMISSC
158 S ^XTMP("RGMT","UT01","TOT LOC SITE MISS TF")=TOTMISSL
159 S ^XTMP("RGMT","UT01","CMOR WITH NO ICN")=NOICN
160 I '$D(RGHLMQ) W !,"Check #1 - Complete"
161 K CMOR,CMORNM,CMORSTA,CNT,DFN,ICN,NAME,NOICN,SITEDA,SITESTA,SSN,TOTMISSC,TOTMISSL
162 Q
163 ;
164TF ; Get totals for unique sites in the TF file (#391.91)
165 I '$D(RGHLMQ) D
166 .W !!,"Check #2 for:"
167 .W !,"- Unique Treating Facility totals."
168 K ^XTMP("RGMT","UT01","TF"),TFCNT S CNT=0
169 S SITE=$P($$SITE^VASITE(),"^",3)
170 S TF=0 F S TF=$O(^DGCN(391.91,"AINST",TF)) Q:'TF D
171 .S CNT=CNT+1 I '$D(RGHLMQ) W:'(CNT#10000) "."
172 .I '$D(TFCNT(TF)) S TFCNT(TF)=0
173 .S TFIEN=0 F S TFIEN=$O(^DGCN(391.91,"AINST",TF,TFIEN)) Q:'TFIEN S TFCNT(TF)=TFCNT(TF)+1
174 S TF=0 F S TF=$O(TFCNT(TF)) Q:'TF D
175 .S TFNM=$P($$NS^XUAF4(TF),"^"),TFSTA=$P($$NS^XUAF4(TF),"^",2) Q:TFSTA=""
176 .S ^XTMP("RGMT","UT01","TF",TFNM,TFSTA)=TFCNT(TF)
177 I '$D(RGHLMQ) W !,"Check #2 - Complete"
178 K CNT,SITE,TF,TFCNT,TFIEN,TFNM,TFSTA
179 Q
180 ;
181TFCHK ; Get totals for duplicates in TF file (#391.91)
182 ;NOICN=# of patients found with remote TFs and no ICN
183 ;LOCICN=# of patients found with remote TFs and a local ICN
184 ;
185 I '$D(RGHLMQ) D
186 .W !!,"Check #3 for:"
187 .W !,"- Duplicate Treating Facility assignments."
188 .W !,"- Patients with Treating Facilities and no ICN."
189 .W !,"- Patients remote treating Facilities and Local ICN."
190 ;
191 K ^XTMP("RGMT","UT01","TOT TFDUP"),^XTMP("RGMT","UT01","TOT NO ICN W/TF"),^XTMP("RGMT","UT01","TOT LOC ICN W/REMOTE TF")
192 S (PTCNT,DUPCNT,NOICN,LOCICN)=0
193 S SITESTA=$P($$SITE^VASITE(),"^",3),SITEDA=$P($$SITE^VASITE(),"^")
194 S DFN=0 F S DFN=$O(^DGCN(391.91,"APAT",DFN)) Q:'DFN D
195 .S PTCNT=PTCNT+1 I '$D(RGHLMQ) W:'(PTCNT#10000) "."
196 .S TF=0 F S TF=$O(^DGCN(391.91,"APAT",DFN,TF)) Q:'TF D
197 ..S MPI0=$G(^DPT(DFN,"MPI")),ICN=$P(MPI0,"^")
198 ..;delete all TFs for patients with no ICN
199 ..I ICN="" D Q
200 ...S NOICN=NOICN+1
201 ...S TFIEN=0 F S TFIEN=$O(^DGCN(391.91,"APAT",DFN,TF,TFIEN)) Q:'TFIEN D
202 ....S ^XTMP("RGMT","UT01","NO ICN WITH REMOTE OR LOCAL TF",DFN,TFIEN)=""
203 ....D DELETE^VAFCTFU(TFIEN)
204 ..;delete all remote TFs for patients with local ICNs
205 ..I $E(ICN,1,3)=SITESTA,TF'=SITEDA D Q
206 ...S TFIEN=0 F S TFIEN=$O(^DGCN(391.91,"APAT",DFN,TF,TFIEN)) Q:'TFIEN D
207 ....S LOCICN=LOCICN+1
208 ....S ^XTMP("RGMT","UT01","LOCAL ICN WITH REMOTE TF",DFN,TFIEN)=""
209 ....D DELETE^VAFCTFU(TFIEN)
210 ..;look for TF dups
211 ..S (TFCNT,TFIEN)=0 F S TFIEN=$O(^DGCN(391.91,"APAT",DFN,TF,TFIEN)) Q:'TFIEN D
212 ...S TFCNT=TFCNT+1 I TFCNT>1 D
213 ....S DUPCNT=DUPCNT+1
214 ....S SSN=$P($G(^DPT(DFN,0)),"^",9)
215 ....S NM=$P($G(^(0)),"^")
216 ....S ^XTMP("RGMT","UT01","TFDUP",DFN,TFIEN)=TF_"^"_NM_"^"_SSN
217 ....D DELETE^VAFCTFU(TFIEN)
218 ;
219 S ^XTMP("RGMT","UT01","TOT TFDUP")=DUPCNT
220 S ^XTMP("RGMT","UT01","TOT NO ICN W/TF")=NOICN
221 S ^XTMP("RGMT","UT01","TOT LOC ICN W/REMOTE TF")=LOCICN
222 I '$D(RGHLMQ) W !,"Check #3 - Complete"
223 K DFN,DUPCNT,ICN,LOCICN,MPI0,NM,NOICN,PTCNT,SITEDA,SITESTA,SSN,TF,TFCNT,TFIEN
224 Q
Note: See TracBrowser for help on using the repository browser.