source: WorldVistAEHR/trunk/r/PCE_PATIENT_CARE_ENCOUNTER-AUTN-EFDP-PX-VSIT--PXRM/PXDELENC.m@ 1150

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

initial load of WorldVistAEHR

File size: 6.7 KB
RevLine 
[613]1PXDELENC ;BAY/RJV-CLEAN UP ENCOUNTERS POINTING TO VISITS THAT DO NOT EXIST. ;14-JUN-2005
2 ;;1.0;PCE;**153**;14-JUL-2004
3EN ;Entry Point.
4 N DIR,DA,ZTRTN,ZTDESC,PXOPT,ZTSK,ZTQUEUED,ZTIO,POP
5 S DIR("?")="Please enter 1, 2, 3, or 4."
6 S DIR("?",1)="Please note: Options 1 -3 work directly from the temporary"
7 S DIR("?",2)="file created by date range under Option 1 - BUILD."
8 S DIR("?",3)="While Option 4 works with the individual patient selected."
9 S DIR("?",4)="Option 4 may show different results than the Build Report"
10 S DIR("?",5)="displays all existing problem encounters by patient."
11 S DIR("?",6)=""
12 S DIR(0)="SO^1:BUILD;2:REPORT;3:FIX ALL BUILD ERRORS;4:FIX INDIVIDUAL"
13 S DIR("L",1)="Select one of the following:"
14 S DIR("L",2)=""
15 S DIR("L",3)="1 Build 2 Report 3 Fix All Build Errors 4 Fix Individual"
16 D ^DIR
17 S PXOPT=Y
18 Q:PXOPT=""
19 K DIR,DA Q:$D(DIRUT)
20 I PXOPT=1 D ASKBLD
21 I PXOPT=2 D PRINT
22 I PXOPT=3 D FIXALL^PXDELFIX
23 I PXOPT=4 D FIXIND^PXDELFIX
24 Q
25ASKBLD ;
26 N PXPAT,PXSDATE,PXENC,PXVISIT,PXPRIM,PXSTART,PXEND,PXCOUNT,PXSEC,PXPRI
27 N PXSDT,PXEDT,PXRANGE,PXREM,Y,%,DIRUT,PXPURGE,PXCREATE,X1,X2,PXATYP
28 D NOW^%DTC S (PXCREATE,X1)=%,X2=120 D C^%DTC S PXPURGE=X
29 S ^XTMP("PXDELENC",0)=PXPURGE_"^"_PXCREATE
30 S Y=$G(^XTMP("PXDELENC","START BUILD")) D DD^%DT S PXSTART=Y
31 S Y=$G(^XTMP("PXDELENC","END BUILD")) D DD^%DT S PXEND=Y
32 I PXEND="RUNNING" D Q
33 .W !!,"Build started on ",PXSTART," still running!"
34 .D WAIT
35 S PXSDT=$P($G(^XTMP("PXDELENC","PXENC",0)),"^",1)
36 S PXEDT=$P($G(^XTMP("PXDELENC","PXENC",0)),"^",2)
37 S Y=PXSDT D DD^%DT S PXSDT=Y
38 S Y=PXEDT D DD^%DT S PXEDT=Y
39 S PXREM=$G(^XTMP("PXDELENC","PXENC","PXCOUNT"))
40 I PXEND'="" D
41 .W !!,"Last Build completed on ",PXEND
42 .W !,"using a date range of ",PXSDT," thru ",PXEDT
43 .I PXREM>0 W !!,"This build contains ",PXREM," items to be fixed.",!
44 .I PXREM=0 W !!,"There are 0 remaining items to be fixed.",!
45 S DIR("A")="Do you wish to continue with NEW Build? "
46 S DIR(0)="Y",DIR("B")="NO"
47 D ^DIR
48 K DA,DIR Q:$D(DIRUT)
49 I Y=0 Q
50ASKBDT ;
51 S %DT="AEPX",%DT("A")="Enter Begin date for build: "
52 D ^%DT S PXSDT=Y
53 I X="^" Q
54 I Y=-1 W !!,"Invalid Date!",! G ASKBDT
55 K %DT,Y
56ASKEDT ;
57 S %DT="AEPX",%DT("A")="Enter Ending date for build: "
58 D ^%DT S PXEDT=Y
59 I X="^" Q
60 I Y=-1 W !!,"Invalid Date!",! G ASKEDT
61 K %DT,Y
62 K ^XTMP("PXDELENC","PXENC")
63 S $P(^XTMP("PXDELENC","PXENC",0),"^",1)=PXSDT
64 S $P(^XTMP("PXDELENC","PXENC",0),"^",2)=PXEDT
65 D CLEAR^VALM1
66 S ZTRTN="BUILD^PXDELENC"
67 S ZTDESC="UTILITY TO LOOK FOR MISSING VISITS"
68 S ZTSAVE("PX*")="",ZTSAVE("XM*")="",ZTIO=""
69 D ^%ZTLOAD
70 I $D(ZTSK) W !,"Request Queued!"
71 D WAIT
72 Q
73BUILD ; Build missing visits enconters.
74 S PXPAT="",PXENC="",PXATYP=""
75 D NOW^%DTC S PXSTART=%
76 S ^XTMP("PXDELENC","START BUILD")=PXSTART
77 S ^XTMP("PXDELENC","END BUILD")="RUNNING"
78 S ^XTMP("PXDELENC",0)=$$FMADD^XLFDT(PXSTART,60)_"^"_PXSTART
79 S PXSDATE=PXSDT
80 F S PXSDATE=$O(^SCE("B",PXSDATE)) Q:PXSDATE=""!($P(PXSDATE,".")>PXEDT) D
81 .F S PXENC=$O(^SCE("B",PXSDATE,PXENC)) Q:PXENC="" D
82 ..S PXPAT=$P($G(^SCE(PXENC,0)),"^",2)
83 ..I $G(PXPAT)="" Q
84 ..S PXATYP=$P($G(^DPT(PXPAT,"S",PXSDATE,0)),"^",2)
85 ..I PXATYP["C" Q
86 ..S PXVISIT=$P($G(^SCE(PXENC,0)),"^",5)
87 ..S PXPRIM=$P($G(^SCE(PXENC,0)),"^",6)
88 ..S PXSEC="" I $P($G(^SCE(PXENC+1,0)),"^",6)=PXENC S PXSEC=PXENC+1
89 ..I $G(PXVISIT)'="" Q
90 ..I $G(PXVISIT)="",$G(PXPRIM)'="" Q
91 ..I $G(PXVISIT)="",$D(^DPT(PXPAT,"S",PXSDATE,0)) D
92 ...S ^XTMP("PXDELENC","PXENC",PXPAT,PXSDATE,PXENC)=$G(PXSEC)
93 D NOW^%DTC S PXEND=%
94 S ^XTMP("PXDELENC","PXENC","PXCOUNT")=$$COUNT()
95 S ^XTMP("PXDELENC","END BUILD")=PXEND
96 D PXMAIL
97 Q
98PRINT ; Print report of missing visits.
99 N PXPAT,PXENC,PXSDATE,PXPATNM,PXNUMNM,%ZIS,PXSDTE,PXEND,PXPAGE
100 N PXPRIM,PXPRIX,PXWARN
101 S PXPAT=0,PXSDATE="",PXENC="",PXEND="",PXPAGE=0,PXWARN=0
102 I $G(^XTMP("PXDELENC","END BUILD"))="RUNNING" D Q
103 .W !!,"Build is running, please wait until complete!"
104 .D WAIT
105 I $G(^XTMP("PXDELENC","PXENC","PXCOUNT"))=0 D Q
106 .W !!,"No missing visits found!"
107 .D WAIT
108 S %ZIS="Q" D ^%ZIS
109 I POP Q
110 I $G(IO("Q"))=1 D Q
111 .N ZTRTN,ZTDESC,ZTSAVE
112 .S ZTRTN="PRINT1^PXDELENC",ZTDESC="MISSING VISIT REPORT"
113 .S ZTSAVE("PX*")=""
114 .D ^%ZTLOAD K IO("Q")
115PRINT1 ;
116 U IO
117 D HDR
118 F S PXPAT=$O(^XTMP("PXDELENC","PXENC",PXPAT)) Q:PXPAT=""!(PXEND) D
119 .F S PXSDATE=$O(^XTMP("PXDELENC","PXENC",PXPAT,PXSDATE)) Q:PXSDATE=""!(PXEND) D
120 ..F S PXENC=$O(^XTMP("PXDELENC","PXENC",PXPAT,PXSDATE,PXENC)) Q:PXENC=""!(PXEND) D
121 ...S PXPRIX=""
122 ...S PXSDTE=PXSDATE
123 ...S Y=PXSDTE D DD^%DT S PXSDTE=Y
124 ...S PXPATNM=$P($G(^DPT(PXPAT,0)),"^",1)
125 ...S PXNUMNM=PXPAT_" - "_PXPATNM
126 ...S PXSEC=$G(^XTMP("PXDELENC","PXENC",PXPAT,PXSDATE,PXENC))
127 ...I '$D(^SCE(PXENC)),$G(PXSEC)'="" S PXPRIX="*",PXWARN=1
128 ...W !,?2,$E(PXNUMNM,1,32),?35,PXSDTE,?55,PXENC,?65,$G(PXSEC)_PXPRIX
129 ...D HDR:$Y+3>IOSL Q:PXEND
130 I PXWARN D
131 .W !!,?15,"* Secondary Encounter exists without Primary!"
132 .W !,?15,"Please note: Secondary Encounters can only be corrected"
133 .W !,?15,"by the FIX ALL option as the FIX INDIVIDUAL option requires"
134 .W !,?15,"the Primary Encounter to exist."
135 D:'PXEND WAIT
136 W @IOF
137 D ^%ZISC
138 Q
139HDR ;
140 N PXSDT,PXEDT
141 S PXSDT=$P($G(^XTMP("PXDELENC","PXENC",0)),"^",1)
142 S PXEDT=$P($G(^XTMP("PXDELENC","PXENC",0)),"^",2)
143 S Y=PXSDT D DD^%DT S PXSDT=Y
144 S Y=PXEDT D DD^%DT S PXEDT=Y
145 I PXPAGE>0,$E(IOST,1,2)="C-" S PXEND=$$EOP() Q:PXEND
146 S PXPAGE=PXPAGE+1
147 W:PXPAGE'=1 @IOF
148 W !!,"Missing Visit Report for Date Range of ",$G(PXSDT)_" - "_$G(PXEDT),!!
149 W !,?2,"Patient IEN - Name",?35,"Appt Date",?55,"Prim Enc",?65,"2nd Enc"
150 W !,?2,"==================",?35,"=========",?55,"========",?65,"======="
151 Q
152EOP() ; End of page check
153 N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
154 I $E(IOST,1,2)'="C-" Q 0 ;NOT TERMINAL
155 S DIR(0)="E"
156 D ^DIR
157 Q 'Y
158PXMAIL ;Send mail message when build complete.
159 N XMAIL,XMSUB,XMDUZ,XMTEXT,PXTEXT,Y,XMY,XMMG,XMZ
160 S Y=$G(PXSTART) D DD^%DT S PXSTART=Y
161 S Y=$G(PXEND) D DD^%DT S PXEND=Y
162 S Y=$G(PXSDT) D DD^%DT S PXSDT=Y
163 S Y=$G(PXEDT) D DD^%DT S PXEDT=Y
164 S ZTQUEUED=1
165 S PXTEXT(1)="PCE DELETE ENCOUNTER W/O VISIT is ready to report & fix."
166 S PXTEXT(2)="Build (PXDELENC) for range of "_$G(PXSDT)_"-"_$G(PXEDT)_" has completed"
167 S PXTEXT(3)="Start time: "_$G(PXSTART)_" End time: "_$G(PXEND)
168 S XMSUB="PCE Delete Encounters W/O Visit...Build Completed.."
169 S XMTEXT="PXTEXT(",XMDUZ=.5,XMY(DUZ)=""
170 D ^XMD
171 S ^XTMP("PXDELENC","PXENC","PXMAIL")=$G(XMZ)_"^"_DUZ_"^"_$G(XMMG)
172 K XMSUB,XMTEXT,XMY
173 Q
174WAIT ;
175 Q:IO'=$G(IO("HOME"))
176 N DIR,X,Y,DIRUT,DUOUT,DTOUT,DIROUT
177 W ! S DIR(0)="E" S DIR("A")="Enter RETURN to continue" D ^DIR W !
178 Q
179COUNT() ;
180 N PXCOUNT,PXPAT,PXSDATE,PXENC
181 S PXCOUNT=0,PXPAT="",PXSDATE="",PXENC=""
182 F S PXPAT=$O(^XTMP("PXDELENC","PXENC",PXPAT)) Q:PXPAT="" D
183 .F S PXSDATE=$O(^XTMP("PXDELENC","PXENC",PXPAT,PXSDATE)) Q:PXSDATE="" D
184 ..F S PXENC=$O(^XTMP("PXDELENC","PXENC",PXPAT,PXSDATE,PXENC)) Q:PXENC="" D
185 ...S PXCOUNT=PXCOUNT+1
186 Q PXCOUNT
187 ;
Note: See TracBrowser for help on using the repository browser.