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

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

Updated version number to 1.5 Beta 1

File size: 4.1 KB
Line 
1BSDX02 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 3/21/11 11:49am
2 ;;1.5T1;BSDX;;Apr 06, 2011
3 ;
4 ; Change Log
5 ; July 15 2010: UJO/SMH - Pass FM dates in instead of US dates for i18n
6 ; March 21 2011: UJO/SMH (v 1.5) - Return new fields: Patient SEX, PID, and DOB
7 ;
8 ;
9CRSCHD(BSDXY,BSDXRES,BSDXSTART,BSDXEND) ;EP
10 ;Entry point for debugging
11 ;
12 ;D DEBUG^%Serenji("CRSCH^BSDX02(.BSDXY,BSDXRES,BSDXSTART,BSDXEND)")
13 Q
14 ;
15CRSCH(BSDXY,BSDXRES,BSDXSTART,BSDXEND,BSDXWKIN) ;
16 ;Called by BSDX CREATE APPT SCHEDULE
17 ;Create Resource Appointment Schedule recordset
18 ;On error, returns 0 in APPOINTMENTID field and error text in NOTE field
19 ;
20 ;$O Thru ^BSDXAPPT("ARSRC", RESOURCE, STARTTIME, APPTID)
21 ;BMXRES is a | delimited list of resource names
22 ;BSDXWKIN - If 1, then return walkins, otherwise skip them
23 ;9-27-2004 Added walkin to returned datatable
24 ;TODO: Change BSDXRES from names to IDs
25 ;
26 N BSDXERR,BSDXIEN,BSDXDEPD,BSDXDEPN,BSDXRESD,BSDXI,BSDXJ,BSDXRESN,BSDXS,BSDXAD,BSDXZ,BSDXQ,BSDXNOD
27 N BSDXPAT,BSDXNOT,BSDXZPCD,BSDXPCD
28 K ^BSDXTMP($J)
29 S BSDXERR=""
30 S BSDXY="^BSDXTMP("_$J_")"
31 S ^BSDXTMP($J,0)="I00020APPOINTMENTID^D00030START_TIME^D00030END_TIME^D00030CHECKIN^D00030AUXTIME^I00020PATIENTID^T00030PATIENTNAME^T00030RESOURCENAME^I00005NOSHOW^T00020HRN^I00005ACCESSTYPEID^I00005WALKIN^T00250NOTE^T00006SEX^T00040PID^D00030DOB"_$C(30)
32 D ^XBKVAR S X="ETRAP^BSDX02",@^%ZOSF("TRAP")
33 ;
34 ; S %DT="T",X=BSDXSTART D ^%DT S BSDXSTART=Y
35 ; I BSDXSTART=-1 S ^BSDXTMP($J,1)=$C(31) Q
36 ; S %DT="T",X=BSDXEND D ^%DT S BSDXEND=Y
37 ; I BSDXEND=-1 S ^BSDXTMP($J,1)=$C(31) Q
38 ;
39 S BSDXI=0
40 D STRES
41 ;
42 S BSDXI=BSDXI+1
43 S ^BSDXTMP($J,BSDXI)=$C(31)
44 Q
45 ;
46STRES ;
47 F BSDXJ=1:1:$L(BSDXRES,"|") S BSDXRESN=$P(BSDXRES,"|",BSDXJ) D
48 . Q:BSDXRESN=""
49 . Q:'$D(^BSDXRES("B",BSDXRESN))
50 . S BSDXRESD=$O(^BSDXRES("B",BSDXRESN,0))
51 . Q:'+BSDXRESD
52 . Q:'$D(^BSDXAPPT("ARSRC",BSDXRESD))
53 . S BSDXS=BSDXSTART-.0001
54 . F S BSDXS=$O(^BSDXAPPT("ARSRC",BSDXRESD,BSDXS)) Q:'+BSDXS Q:BSDXS>BSDXEND D
55 . . S BSDXAD=0 F S BSDXAD=$O(^BSDXAPPT("ARSRC",BSDXRESD,BSDXS,BSDXAD)) Q:'+BSDXAD D STCOMM(BSDXAD,BSDXRESN)
56 Q
57 ;
58STCOMM(BSDXAD,BSDXRESN) ;
59 ;BSDXAD is the appointment IEN
60 N BSDXC,BSDXQ,BSDXZ,BSDXSUBC,BSDXHRN,BSDXPATD,BSDXATID,BSDXISWK
61 Q:'$D(^BSDXAPPT(BSDXAD,0))
62 S BSDXNOD=^BSDXAPPT(BSDXAD,0)
63 Q:$P(BSDXNOD,U,12)]"" ;CANCELLED
64 S BSDXISWK=0
65 S:$P(BSDXNOD,U,13)="y" BSDXISWK=1
66 I +$G(BSDXWKIN) Q:BSDXISWK ;Don't return walkins if appt is WALKIN and BSDXWKIN is 1
67 S BSDXZ=BSDXAD_"^"
68 F BSDXQ=1:1:4 D
69 . S Y=$P(BSDXNOD,U,BSDXQ)
70 . X ^DD("DD") S Y=$TR(Y,"@"," ")
71 . S BSDXZ=BSDXZ_Y_"^"
72 S BSDXPATD=$P(BSDXNOD,U,5)
73 S BSDXZ=BSDXZ_BSDXPATD_"^" ;PATIENT ID
74 S BSDXPAT=""
75 I BSDXPATD]"",$D(^DPT(BSDXPATD,0)) S BSDXPAT=$P(^DPT(BSDXPATD,0),U)
76 S BSDXZ=BSDXZ_BSDXPAT_"^" ;PATIENT NAME
77 S BSDXZ=BSDXZ_BSDXRESN_"^" ;RESOURCENAME
78 S BSDXZ=BSDXZ_+$P(BSDXNOD,U,10)_"^" ;NOSHOW
79 S BSDXHRN=""
80 I $D(DUZ(2)),DUZ(2)>0 S BSDXHRN=$P($G(^AUPNPAT(BSDXPATD,41,DUZ(2),0)),U,2) ;HRN
81 S BSDXZ=BSDXZ_BSDXHRN_"^"
82 S BSDXATID=$P(BSDXNOD,U,6)
83 S:'+BSDXATID BSDXATID=0 ;UNKNOWN TYPE
84 S BSDXZ=BSDXZ_BSDXATID_"^"_BSDXISWK_"^"
85 S BSDXI=BSDXI+1
86 S ^BSDXTMP($J,BSDXI)=BSDXZ
87 ;NOTE
88 S BSDXNOT="",BSDXQ=0 F S BSDXQ=$O(^BSDXAPPT(BSDXAD,1,BSDXQ)) Q:'+BSDXQ D
89 . S BSDXNOT=$G(^BSDXAPPT(BSDXAD,1,BSDXQ,0))
90 . S:$E(BSDXNOT,$L(BSDXNOT)-1,$L(BSDXNOT))'=" " BSDXNOT=BSDXNOT_" "
91 . S BSDXI=BSDXI+1
92 . S ^BSDXTMP($J,BSDXI)=BSDXNOT
93 S ^BSDXTMP($J,BSDXI)=^BSDXTMP($J,BSDXI)_U ; Add "^" to separate note from next fields.
94 S BSDXI=BSDXI+1
95 ; new code for V1.5. Extra fields to return.
96 N SEX S SEX=$$GET1^DIQ(2,BSDXPATD,.02) ; SEX
97 N PID S PID=$$GET1^DIQ(2,BSDXPATD,.363) ; PRIMARY LONG ID
98 ; Note strange way I retrieve the value. B/c DOB Output Transform
99 ; Outputs it in MM/DD/YYYY format, which is ambigous for C#.
100 N DOB S DOB=$$FMTE^XLFDT($$GET1^DIQ(2,BSDXPATD,.03,"I")) ; DOB
101 S ^BSDXTMP($J,BSDXI)=SEX_U_PID_U_DOB_$C(30)
102 ; end new code
103 Q
104 ;
105ERR(BSDXI,BSDXERR) ;Error processing
106 S BSDXI=BSDXI+1
107 S ^BSDXTMP($J,BSDXI)="0^^^^^^^^^^^"_BSDXERR_$C(30)
108 S BSDXI=BSDXI+1
109 S ^BSDXTMP($J,BSDXI)=$C(31)
110 Q
111 ;
112ETRAP ;EP Error trap entry
113 D ^%ZTER
114 I '$D(BSDXI) N BSDXI S BSDXI=999999
115 S BSDXI=BSDXI+1
116 D ERR(BSDXI,"BSDX31 Error: "_$G(%ZTERROR))
117 Q
Note: See TracBrowser for help on using the repository browser.