source: Scheduling/trunk/m/BSDX02.m@ 855

Last change on this file since 855 was 851, checked in by Sam Habiel, 14 years ago

Fixes to support i18n (Receive FM dates from C# instead of culture specific date).Also, fix for Rebooking. Now it works.

File size: 3.5 KB
Line 
1BSDX02 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 7/11/10 5:17pm
2 ;;2.0;IHS WINDOWS SCHEDULING;;NOV 01, 2007
3 ;
4 ;
5CRSCHD(BSDXY,BSDXRES,BSDXSTART,BSDXEND) ;EP
6 ;Entry point for debugging
7 ;
8 ;D DEBUG^%Serenji("CRSCH^BSDX02(.BSDXY,BSDXRES,BSDXSTART,BSDXEND)")
9 Q
10 ;
11CRSCH(BSDXY,BSDXRES,BSDXSTART,BSDXEND,BSDXWKIN) ;
12 ;Called by BSDX CREATE APPT SCHEDULE
13 ;Create Resource Appointment Schedule recordset
14 ;On error, returns 0 in APPOINTMENTID field and error text in NOTE field
15 ;
16 ;$O Thru ^BSDXAPPT("ARSRC", RESOURCE, STARTTIME, APPTID)
17 ;BMXRES is a | delimited list of resource names
18 ;BSDXWKIN - If 1, then return walkins, otherwise skip them
19 ;9-27-2004 Added walkin to returned datatable
20 ;TODO: Change BSDXRES from names to IDs
21 ;
22 N BSDXERR,BSDXIEN,BSDXDEPD,BSDXDEPN,BSDXRESD,BSDXI,BSDXJ,BSDXRESN,BSDXS,BSDXAD,BSDXZ,BSDXQ,BSDXNOD
23 N BSDXPAT,BSDXNOT,BSDXZPCD,BSDXPCD
24 K ^BSDXTMP($J)
25 S BSDXERR=""
26 S BSDXY="^BSDXTMP("_$J_")"
27 S ^BSDXTMP($J,0)="I00020APPOINTMENTID^D00030START_TIME^D00030END_TIME^D00030CHECKIN^D00030AUXTIME^I00020PATIENTID^T00030PATIENTNAME^T00030RESOURCENAME^I00005NOSHOW^T00020HRN^I00005ACCESSTYPEID^I00005WALKIN^T00250NOTE"_$C(30)
28 D ^XBKVAR S X="ETRAP^BSDX02",@^%ZOSF("TRAP")
29 ;
30 ; S %DT="T",X=BSDXSTART D ^%DT S BSDXSTART=Y
31 ; I BSDXSTART=-1 S ^BSDXTMP($J,1)=$C(31) Q
32 ; S %DT="T",X=BSDXEND D ^%DT S BSDXEND=Y
33 ; I BSDXEND=-1 S ^BSDXTMP($J,1)=$C(31) Q
34 ;
35 S BSDXI=0
36 D STRES
37 ;
38 S BSDXI=BSDXI+1
39 S ^BSDXTMP($J,BSDXI)=$C(31)
40 Q
41 ;
42STRES ;
43 F BSDXJ=1:1:$L(BSDXRES,"|") S BSDXRESN=$P(BSDXRES,"|",BSDXJ) D
44 . Q:BSDXRESN=""
45 . Q:'$D(^BSDXRES("B",BSDXRESN))
46 . S BSDXRESD=$O(^BSDXRES("B",BSDXRESN,0))
47 . Q:'+BSDXRESD
48 . Q:'$D(^BSDXAPPT("ARSRC",BSDXRESD))
49 . S BSDXS=BSDXSTART-.0001
50 . F S BSDXS=$O(^BSDXAPPT("ARSRC",BSDXRESD,BSDXS)) Q:'+BSDXS Q:BSDXS>BSDXEND D
51 . . S BSDXAD=0 F S BSDXAD=$O(^BSDXAPPT("ARSRC",BSDXRESD,BSDXS,BSDXAD)) Q:'+BSDXAD D STCOMM(BSDXAD,BSDXRESN)
52 Q
53 ;
54STCOMM(BSDXAD,BSDXRESN) ;
55 ;BSDXAD is the appointment IEN
56 N BSDXC,BSDXQ,BSDXZ,BSDXSUBC,BSDXHRN,BSDXPATD,BSDXATID,BSDXISWK
57 Q:'$D(^BSDXAPPT(BSDXAD,0))
58 S BSDXNOD=^BSDXAPPT(BSDXAD,0)
59 Q:$P(BSDXNOD,U,12)]"" ;CANCELLED
60 S BSDXISWK=0
61 S:$P(BSDXNOD,U,13)="y" BSDXISWK=1
62 I +$G(BSDXWKIN) Q:BSDXISWK ;Don't return walkins if appt is WALKIN and BSDXWKIN is 1
63 S BSDXZ=BSDXAD_"^"
64 F BSDXQ=1:1:4 D
65 . S Y=$P(BSDXNOD,U,BSDXQ)
66 . X ^DD("DD") S Y=$TR(Y,"@"," ")
67 . S BSDXZ=BSDXZ_Y_"^"
68 S BSDXPATD=$P(BSDXNOD,U,5)
69 S BSDXZ=BSDXZ_BSDXPATD_"^" ;PATIENT ID
70 S BSDXPAT=""
71 I BSDXPATD]"",$D(^DPT(BSDXPATD,0)) S BSDXPAT=$P(^DPT(BSDXPATD,0),U)
72 S BSDXZ=BSDXZ_BSDXPAT_"^" ;PATIENT NAME
73 S BSDXZ=BSDXZ_BSDXRESN_"^" ;RESOURCENAME
74 S BSDXZ=BSDXZ_+$P(BSDXNOD,U,10)_"^" ;NOSHOW
75 S BSDXHRN=""
76 I $D(DUZ(2)),DUZ(2)>0 S BSDXHRN=$P($G(^AUPNPAT(BSDXPATD,41,DUZ(2),0)),U,2) ;HRN
77 S BSDXZ=BSDXZ_BSDXHRN_"^"
78 S BSDXATID=$P(BSDXNOD,U,6)
79 S:'+BSDXATID BSDXATID=0 ;UNKNOWN TYPE
80 S BSDXZ=BSDXZ_BSDXATID_"^"_BSDXISWK_"^"
81 S BSDXI=BSDXI+1
82 S ^BSDXTMP($J,BSDXI)=BSDXZ
83 ;NOTE
84 S BSDXNOT="",BSDXQ=0 F S BSDXQ=$O(^BSDXAPPT(BSDXAD,1,BSDXQ)) Q:'+BSDXQ D
85 . S BSDXNOT=$G(^BSDXAPPT(BSDXAD,1,BSDXQ,0))
86 . S:$E(BSDXNOT,$L(BSDXNOT)-1,$L(BSDXNOT))'=" " BSDXNOT=BSDXNOT_" "
87 . S BSDXI=BSDXI+1
88 . S ^BSDXTMP($J,BSDXI)=BSDXNOT
89 S BSDXI=BSDXI+1
90 S ^BSDXTMP($J,BSDXI)=$C(30)
91 Q
92 ;
93ERR(BSDXI,BSDXERR) ;Error processing
94 S BSDXI=BSDXI+1
95 S ^BSDXTMP($J,BSDXI)="0^^^^^^^^^^^"_BSDXERR_$C(30)
96 S BSDXI=BSDXI+1
97 S ^BSDXTMP($J,BSDXI)=$C(31)
98 Q
99 ;
100ETRAP ;EP Error trap entry
101 D ^%ZTER
102 I '$D(BSDXI) N BSDXI S BSDXI=999999
103 S BSDXI=BSDXI+1
104 D ERR(BSDXI,"BSDX31 Error: "_$G(%ZTERROR))
105 Q
Note: See TracBrowser for help on using the repository browser.