source: Scheduling/trunk/m/BSDX31.m@ 755

Last change on this file since 755 was 614, checked in by Sam Habiel, 15 years ago

Initial committ of scheduling package

File size: 4.4 KB
RevLine 
[614]1BSDX31 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ;
2 ;;2.0;IHS WINDOWS SCHEDULING;;NOV 01, 2007
3 ;
4 ;
5NOSHOWD(BSDXY,BSDXAPTID,BSDXNS) ;EP
6 ;Entry point for debugging
7 ;
8 ;D DEBUG^%Serenji("NOSHOW^BSDX31(.BSDXY,BSDXAPTID,BSDXNS)")
9 Q
10 ;
11NOSHOW(BSDXY,BSDXAPTID,BSDXNS) ;EP
12 ;Called by BSDX NOSHOW
13 ;Sets appointment noshow flag in BSDX APPOINTMENT file
14 ;BSDXAPTID is entry number in BSDX APPOINTMENT file
15 ;BSDXNS = 1: NOSHOW, 0: CANCEL NOSHO
16 ;Calls CANCEL^BSDAPI to set noshow data in ^DPT
17 ;Returns error code in recordset field ERRORID
18 ;
19 N BSDXNOD,BSDXPATID,BSDXSTART,BSDXID,BSDXI,BSDXZ,BSDXERR,BSDXMSG,BSDXFDA,BSDXIENS
20 N BSDXNOEV
21 S BSDXNOEV=1 ;Don't execute protocol
22 ;
23 D ^XBKVAR S X="ETRAP^BSDX31",@^%ZOSF("TRAP")
24 S BSDXI=0
25 K ^BSDXTMP($J)
26 S BSDXY="^BSDXTMP("_$J_")"
27 S ^BSDXTMP($J,BSDXI)="I00020ERRORID^T00030ERRORTEXT"_$C(30)
28 S BSDXI=BSDXI+1
29 TSTART
30 I '+BSDXAPTID D ERR(0,"BSDX31: Invalid Appointment ID") Q
31 I '$D(^BSDXAPPT(BSDXAPTID,0)) D ERR(0,"BSDX31: Invalid Appointment ID") Q
32 S BSDXNS=+BSDXNS
33 I BSDXNS'=1&(BSDXNS'=0) D ERR(0,"BSDX31: Invalid No Show value") Q
34 ;
35 ;Edit BSDX APPOINTMENT entry NOSHOW field
36 S BSDXNOD=^BSDXAPPT(BSDXAPTID,0)
37 I BSDXNOD="" D ERR(0,"BSDX31: Invalid Appointment ID") Q
38 S BSDXPATID=$P(BSDXNOD,U,5)
39 S BSDXSTART=$P(BSDXNOD,U)
40 ;
41 D BSDXNOS(BSDXAPTID,BSDXNS)
42 I $D(BSDXMSG("DIERR")) S BSDXMSG=$G(BSDXMSG("DIERR",1,"TEXT",1)) D ERR(0,"BSDX31: "_BSDXMSG) Q
43 ;
44 S BSDXSC1=$P(BSDXNOD,U,7) ;RESOURCEID
45 I BSDXSC1]"",$D(^BSDXRES(BSDXSC1,0)) D I $G(BSDXZ)]"" S BSDXERR="BSDX31: APNOSHO Returned: "_BSDXZ D ERR(0,BSDXERR) Q
46 . S BSDXNOD=^BSDXRES(BSDXSC1,0)
47 . S BSDXSC1=$P(BSDXNOD,U,4) ;HOSPITAL LOCATION
48 . I BSDXSC1]"",$D(^SC(BSDXSC1,0)) D APNOSHO(.BSDXZ,BSDXSC1,BSDXPATID,BSDXSTART,BSDXNS)
49 ;
50 TCOMMIT
51 S BSDXI=BSDXI+1
52 S ^BSDXTMP($J,BSDXI)="1^"_$C(30)
53 S BSDXI=BSDXI+1
54 S ^BSDXTMP($J,BSDXI)=$C(31)
55 Q
56 ;
57APNOSHO(BSDXZ,BSDXSC1,BSDXDFN,BSDXSD,BSDXNS) ;
58 ; update file 2 info
59 ;Set noshow for patient BSDXDFN in clinic BSDXSC1
60 ;at time BSDXSD
61 N BSDXC,%H,BSDXCDT,BSDXIEN
62 N BSDXIENS,BSDXFDA,BSDXMSG
63 S %H=$H D YMD^%DTC
64 S BSDXCDT=X+%
65 ;
66 S BSDXIENS=BSDXSD_","_BSDXDFN_","
67 I +BSDXNS D
68 . S BSDXFDA(2.98,BSDXIENS,3)="N"
69 . S BSDXFDA(2.98,BSDXIENS,14)=DUZ
70 . S BSDXFDA(2.98,BSDXIENS,15)=BSDXCDT
71 E D
72 . S BSDXFDA(2.98,BSDXIENS,3)=""
73 . S BSDXFDA(2.98,BSDXIENS,14)=""
74 . S BSDXFDA(2.98,BSDXIENS,15)=""
75 K BSDXIEN
76 D UPDATE^DIE("","BSDXFDA","BSDXIEN","BSDXMSG")
77 S BSDXZ=$G(BSDXMSG("DIERR",1,"TEXT",1))
78 Q
79 ;
80BSDXNOS(BSDXAPTID,BSDXNS) ;
81 ;
82 N BSDXFDA,BSDXIENS
83 S BSDXIENS=BSDXAPTID_","
84 S BSDXFDA(9002018.4,BSDXIENS,.1)=BSDXNS ;NOSHOW
85 D FILE^DIE("","BSDXFDA","BSDXMSG")
86 ;
87 Q
88 ;
89NOSEVT(BSDXPAT,BSDXSTART,BSDXSC) ;EP Called by BSDX NOSHOW APPOINTMENT event
90 ;when appointments NOSHOW via PIMS interface.
91 ;Propagates NOSHOW to BSDXAPPT and raises refresh event to running GUI clients
92 ;
93 Q:+$G(BSDXNOEV)
94 Q:'+$G(BSDXSC)
95 Q:$G(SDATA("AFTER","STATUS"))["AUTO RE-BOOK"
96 N BSDXSTAT,BSDXFOUND,BSDXRES
97 S BSDXSTAT=1
98 S:$G(SDATA("BEFORE","STATUS"))["NO-SHOW" BSDXSTAT=0
99 S BSDXFOUND=0
100 I $D(^BSDXRES("ALOC",BSDXSC)) S BSDXRES=$O(^BSDXRES("ALOC",BSDXSC,0)) S BSDXFOUND=$$NOSEVT1(BSDXRES,BSDXSTART,BSDXPAT,BSDXSTAT)
101 I BSDXFOUND D NOSEVT3(BSDXRES) Q
102 I $D(^BXDXRES("ASSOC",BSDXSC)) S BSDXRES=$O(^BSDXRES("ASSOC",BSDXSC,0)) S BSDXFOUND=$$NOSEVT1(BSDXRES,BSDXSTART,BSDXPAT,BSDXSTAT)
103 I BSDXFOUND D NOSEVT3(BSDXRES)
104 Q
105 ;
106NOSEVT1(BSDXRES,BSDXSTART,BSDXPAT,BSDXSTAT) ;
107 ;Get appointment id in BSDXAPT
108 ;If found, call BSDXNOS(BSDXAPPT) and return 1
109 ;else return 0
110 N BSDXFOUND,BSDXAPPT
111 S BSDXFOUND=0
112 Q:'+$G(BSDXRES) BSDXFOUND
113 Q:'$D(^BSDXAPPT("ARSRC",BSDXRES,BSDXSTART)) BSDXFOUND
114 S BSDXAPPT=0 F S BSDXAPPT=$O(^BSDXAPPT("ARSRC",BSDXRES,BSDXSTART,BSDXAPPT)) Q:'+BSDXAPPT D Q:BSDXFOUND
115 . S BSDXNOD=$G(^BSDXAPPT(BSDXAPPT,0)) Q:BSDXNOD=""
116 . I $P(BSDXNOD,U,5)=BSDXPAT,$P(BSDXNOD,U,12)="" S BSDXFOUND=1 Q
117 I BSDXFOUND,+$G(BSDXAPPT) D BSDXNOS(BSDXAPPT,BSDXSTAT)
118 Q BSDXFOUND
119 ;
120NOSEVT3(BSDXRES) ;
121 ;Call RaiseEvent to notify GUI clients
122 ;
123 N BSDXRESN
124 S BSDXRESN=$G(^BSDXRES(BSDXRES,0))
125 Q:BSDXRESN=""
126 S BSDXRESN=$P(BSDXRESN,"^")
127 D EVENT^BMXMEVN("BSDX SCHEDULE",BSDXRESN)
128 Q
129 ;
130 ;
131ERR(BSDXERID,ERRTXT) ;Error processing
132 S:'+$G(BSDXI) BSDXI=999999
133 S BSDXI=BSDXI+1
134 TROLLBACK
135 S ^BSDXTMP($J,BSDXI)=BSDXERID_"^"_ERRTXT_$C(30)
136 S BSDXI=BSDXI+1
137 S ^BSDXTMP($J,BSDXI)=$C(31)
138 Q
139 ;
140ETRAP ;EP Error trap entry
141 D ^%ZTER
142 I '$D(BSDXI) N BSDXI S BSDXI=999999
143 S BSDXI=BSDXI+1
144 D ERR(0,"BSDX31 Error: "_$G(%ZTERROR))
145 Q
146 ;
147IMHERE(BSDXRES) ;EP
148 ;Entry point for BSDX IM HERE remote procedure
149 S BSDXRES=1
150 Q
151 ;
Note: See TracBrowser for help on using the repository browser.