source: FOIAVistA/tag/r/SCHEDULING-SD-SC/SCDXHLDR.m@ 658

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

initial load of FOIAVistA 6/30/08 version

File size: 5.3 KB
Line 
1SCDXHLDR ;ALB/JLU;Ambulatory care event handler;4/30/96
2 ;;5.3;Scheduling;**44,99,126,66,132,245**;5/1/96
3 ;This routine is the Ambulatory care event handler. It will hang on
4 ;the Scheduling event driver and monitor the types of events. When a
5 ;check out, edit to a check out or deletion of a check out occurs this
6 ;routine will update the Transmitted outpatient encounter file.
7 ;
8EN ;Main entry point
9 ;
10 I $D(SDSTPAMB) G ENQ ;this will stop the logging of events.
11 I '$D(SDAMEVT) G ENQ
12 I SDAMEVT'>4!(SDAMEVT>9) G ENQ ;check out, add/edit and add/edit change
13 N SDOE,SDPROC,SDBEFORE,SDAFTER,EVTDT,CLINIC,XMIT
14 S SDPROC=0
15 F S SDPROC=$O(^TMP("SDEVT",$J,SDHDL,SDPROC)) Q:'SDPROC I SDPROC'=4 DO
16 .S SDOE=0
17 .F S SDOE=$O(^TMP("SDEVT",$J,SDHDL,SDPROC,"SDOE",SDOE)) Q:'SDOE DO
18 ..K XMIT
19 ..D NOW^%DTC S EVTDT=%
20 ..S SDAFTER=$G(^TMP("SDEVT",$J,SDHDL,SDPROC,"SDOE",SDOE,0,"AFTER"))
21 ..S SDBEFORE=$G(^("BEFORE")) ;naked reference from previous line
22 ..;
23 ..;Screen out test patients
24 ..S DFN=$S((SDAFTER'=""):$P(SDAFTER,U,2),(SDBEFORE'=""):$P(SDBEFORE,U,2),1:0)
25 ..I DFN Q:$$TESTPAT^VADPT(DFN)
26 ..;
27 ..; screen out non counts
28 ..I SDAFTER]"" S CLINIC=$P(SDAFTER,U,4) Q:$$NONCNT($P(SDAFTER,U,4))
29 ..I SDBEFORE]"" S CLINIC=$P(SDBEFORE,U,4) Q:$$NONCNT($P(SDBEFORE,U,4))
30 ..;
31 ..; handling of delete encounters and check outs
32 ..I SDAFTER]"",SDBEFORE]"",SDAFTER'=SDBEFORE,'$$COMPL(SDAFTER) D LOAD("DELETE",SDOE,EVTDT,SDBEFORE) Q ;DELETION OF A CHECK OUT
33 ..I SDBEFORE]"",SDAFTER']"",SDPROC=2,'+$P(SDBEFORE,U,6) D LOAD("DELETE",SDOE,EVTDT,SDBEFORE) Q ;delete of a stand alone add/edit
34 ..I SDBEFORE]"",SDAFTER']"",SDPROC=2,+$P(SDBEFORE,U,6) Q ;delete of add/edit from an appt. IT HAS ALREADY BEEN MARKED
35 ..;;;I SDBEFORE]"",SDAFTER']"",SDPROC=2,+$P(SDBEFORE,U,6) D LOAD("EDIT",SDOE,EVTDT,SDBEFORE) Q ;THIS IS FROM ABOVE. KEPT FOR REFERENCE
36 ..;
37 ..;screen out not checked out encounters
38 ..I '$S(SDAFTER]"":$$COMPL(SDAFTER),SDBEFORE]"":$$COMPL(SDBEFORE),1:0) Q
39 ..;
40 ..;any loads or edits
41 ..I SDBEFORE]"",SDAFTER]"" D LOAD("EDIT",SDOE,EVTDT) ;edit of C/O
42 ..I SDBEFORE']"",SDAFTER]"" D LOAD("ADD",SDOE,EVTDT) ;new encounter at C/O
43 ..Q
44 .Q
45 ;
46ENQ ;
47 Q
48 ;
49NONCNT(IEN) ;this function determines if the clinic is non count or not
50 ;INPUT IEN the poitner to the hospital location.
51 ;OUTPUT 1 if a non count
52 ; 0 if not a non count
53 I '$D(IEN) S ANS=0 G NONCNTQ
54 I 'IEN S ANS=0 G NONCNTQ
55 S ANS=$S($P(^SC(IEN,0),U,17)="Y":1,1:0)
56NONCNTQ Q ANS
57 ;
58COMPL(NODE) ;this function call returns whether or not the check out
59 ;process is complete or not. 1 for complete 0 for not
60 ;
61 Q $S(+$P(NODE,U,7):1,1:0)
62 ;
63LOAD(ACTION,IEN,EVTDT,NODE) ;
64 ;ACTION is what type of action caused this event
65 ;IEN is the pointer to the outpatient encounter file
66 ;EVTDT is the date this action occured
67 ;NODE is the zero node of the outpatient encounter file
68 ;
69 N EVNT,PAR
70 ;
71 I ACTION'="DELETE" DO
72 .I $D(^SCE(IEN,0)) S PAR=$P(^SCE(IEN,0),U,6)
73 .E S PAR=$P(NODE,U,6)
74 .S IEN=$S(+PAR:PAR,1:IEN)
75 .S EVNT=$S(ACTION="ADD":1,1:2)
76 .S XMIT=$$FINDXMIT^SCDXFU01(IEN)
77 .I 'XMIT S XMIT=$$CRTXMIT^SCDXFU01(IEN,"",EVTDT)
78 .I +XMIT>0 D STREEVNT^SCDXFU01(XMIT,EVNT,EVTDT),XMITFLAG^SCDXFU01(XMIT,0)
79 .Q
80 ;
81 I ACTION="DELETE" DO
82 .N DELENT,TRANENT,DELENCT,PAR,NTNEED
83 .S PAR=$P(NODE,U,6)
84 .S IEN=$S(+PAR:PAR,1:IEN)
85 .;
86 .;Encounter never transmitted to or accepted by NPCD
87 .I (('$$XMITED^SCDXFU03(IEN))&('$$ACCEPTED^SCDXFU03(IEN))) S NTNEED=""
88 .;Another parent encounter has same Visit ID (i.e. duplicate encounter)
89 .I ($$VIDCNT^SCDXFU03($P(NODE,"^",20),IEN)) S NTNEED=""
90 .;
91 .S DELENT=$$CRTDEL^SCDXFU02($P(NODE,U,1),$P(NODE,U,2),EVTDT,NODE)
92 .I DELENT<0 S DELENT=$$DELXMIT^SCDXFU03(IEN,1) Q
93 .;
94 .S XMIT=$$CRTXMIT^SCDXFU01(IEN,DELENT,EVTDT)
95 .I XMIT<0 S DELENT=$$DELXMIT^SCDXFU03(IEN,1) Q
96 .;
97 .;Delete entry in transmission file (409.73) - not needed
98 .I $D(NTNEED) S DELENT=$$DELXMIT^SCDXFU03(DELENT,2) Q
99 .;
100 .D XMITFLAG^SCDXFU01(XMIT,0)
101 .Q
102 Q
103 ;
104VALIDATE(XMIT,CLINIC) ;this entry point performs the validation at check out.
105 ;
106 ;INPUT - XMIT this is the IEN of an entry in the transmit file 409.73
107 S XMIT=+$G(XMIT)
108 S CLINIC=+$G(CLINIC)
109 I XMIT<1!(CLINIC<1) G VALQ
110 N VAL
111 S VAL=$$VALWL^SCMSVUT2(+$G(CLINIC))
112 I VAL<1 G VALQ
113 I 'SDMODE,'$D(ZTQUEUED),'$D(VALQUIET) W !!,"Performing Ambulatory Care Validation Checks.",!
114 S ERR=$$VALIDATE^SCMSVUT2(XMIT)
115 I SDMODE!($D(ZTQUEUED))!($D(VALQUIET)) G VALQ
116 I ERR<1 DO G VALQ
117 .W !,"No validation errors found!"
118 .Q
119 S DIR(0)="Y"
120 S DIR("B")="YES"
121 S DIR("A")="Do you wish to correct the validation errors"
122 D ^DIR
123 K DIR
124 I Y<1 G VALQ
125 ;
126 D ENP^SCENI0(XMIT)
127 ;
128VALQ Q
129 ;
130FINAL(VISIT,PXKVST) ;
131 ;INPUT VISIT - the IEN of the visit at hand.
132 ;
133 Q:$D(SDIEMM)
134 Q:'$D(VISIT)
135 Q:VISIT=""
136 Q:$D(VALSTP)
137 Q:$D(^TMP("PXKSAVE",$J))
138 N ENC,CLN,XMT,SDMODE
139 S ENC=0
140 F S ENC=$O(^SCE("AVSIT",VISIT,ENC)) Q:ENC="" I $P(^SCE(ENC,0),U,6)="" Q
141 I ENC="" Q
142 Q:'$D(^SCE(ENC,0))
143 Q:'$$COMPL(^SCE(ENC,0))
144 S CLN=$P(^SCE(ENC,0),U,4)
145 S XMT=+$O(^SD(409.73,"AENC",ENC,0))
146 I 'XMT Q
147 S SDMODE=0
148 D TERM
149 D VALIDATE(XMT,CLN)
150 Q
151 ;
152TERM ;this is to reset the io variables for lsitman to function properly
153 ;when coming from PCE.
154 N X
155 S X="IORVON;IORVOFF;IOIL;IOSTBM;IOSC;IORC;IOEDEOP;IOINHI;IOINORM;IOUON;IOUOFF;IOBON;IOBOFF;IOSGR0"
156 ;;;S X="IORVON;IORVOFF;IOSC;IORC;IOEDEOP;IOINHI;IOINORM;IOUON;IOUOFF;IOBON;IOBOFF;IOSGR0"
157 D ENDR^%ZISS
158 Q
159 ;
160OK() ;
161 I SDAMEVT=6,SDBEFORE="",SDAFTER]"" Q 0
162 Q 1
163 ;
Note: See TracBrowser for help on using the repository browser.