Index: Scheduling/trunk/m/BSDX08.m
===================================================================
--- Scheduling/trunk/m/BSDX08.m	(revision 1461)
+++ Scheduling/trunk/m/BSDX08.m	(revision 1467)
@@ -1,3 +1,3 @@
-BSDX08	; VW/UJO/SMH - WINDOWS SCHEDULING RPCS ; 6/26/12 10:49am
+BSDX08	; VW/UJO/SMH - WINDOWS SCHEDULING RPCS ; 7/5/12 12:39pm
 	;;1.7T1;BSDX;;Aug 31, 2011;Build 18
 	; 
@@ -16,4 +16,6 @@
 	; 3120625 VEN/SMH v1.7
 	;  - Transactions removed. Code refactored to work w/o txns.
+	;  - Moved AVUPDT to AVUPDTCN in BSDXAPI1. BSDXAPI takes care of calling
+	;    that.
 	; 
 	; Error Reference:
@@ -128,16 +130,7 @@
 	; If error happens, must rollback ^BSDXAPPT
 	I BSDXLOC D  QUIT:BSDXERR
-	. N BSDXLEN S BSDXLEN=$$APPLEN^BSDXAPI(BSDXPATID,BSDXLOC,BSDXSTART) ; appt length
 	. S BSDXERR=$$CANCEL^BSDXAPI(.BSDXC) ; Cancel through BSDXAPI
 	. ; Rollback BSDXAPPT if error occurs
-	. ; TODO: If an M error occurs in BSDXAPI, ETRAP gets called, ^BSDXTMP is
-	. ;       populated, then the output of $$CANCEL is the output of ETRAP.
-	. ;       Then, we see that BSDXERR is true, and we do another write,
-	. ;       which deletes the information we had in ^BSDXTMP. What to do???
 	. I BSDXERR D ERR(BSDXI,"-9^BSDX08: BSDXAPI returned an error: "_$P(BSDXERR,U,2)),ROLLBACK(BSDXAPTID)  QUIT
-	. ;
-	. ; Update Legacy PIMS clinic Availability ; no failure expected here.
-	. D AVUPDT(BSDXLOC,BSDXSTART,BSDXLEN)
-	;
 	;
 	L -^BSDXAPPT(BSDXAPTID)
@@ -146,50 +139,4 @@
 	S BSDXI=BSDXI+1
 	S ^BSDXTMP($J,BSDXI)=$C(31)
-	Q
-	;
-AVUPDT(BSDXSCD,BSDXSTART,BSDXLEN)	;Update Legacy PIMS Clinic availability
-	;See SDCNP0
-	N SD,S  ; Start Date
-	S (SD,S)=BSDXSTART
-	N I ; Clinic IEN in 44
-	S I=BSDXSCD
-	; if day has no schedule in legacy PIMS, forget about this update.
-	Q:'$D(^SC(I,"ST",SD\1,1))
-	N SL ; Clinic characteristics node (length of appt, when appts start etc)
-	S SL=^SC(I,"SL")
-	N X ; Hour Clinic Display Begins
-	S X=$P(SL,U,3)
-	N STARTDAY ; When does the day start?
-	S STARTDAY=$S($L(X):X,1:8) ; If defined, use it; otherwise, 8am
-	N SB ; ?? Who knows? Day Start - 1 divided by 100.
-	S SB=STARTDAY-1/100
-	S X=$P(SL,U,6) ; Now X is Display increments per hour
-	N HSI ; Slots per hour, try 1
-	S HSI=$S(X:X,1:4) ; if defined, use it; otherwise, 4
-	N SI ; Slots per hour, try 2
-	S SI=$S(X="":4,X<3:4,X:X,1:4) ; If slots "", or less than 3, then 4
-	N STR ; ??
-	S STR="#@!$* XXWVUTSRQPONMLKJIHGFEDCBA0123456789jklmnopqrstuvwxyz"
-	N SDDIF ; Slots per hour diff??
-	S SDDIF=$S(HSI<3:8/HSI,1:2)
-	S SL=BSDXLEN ; Dammit, reusing variable; SL now Appt Length from GUI
-	S S=^SC(I,"ST",SD\1,1) ; reusing var again; S now Day Pattern from PIMS
-	N Y ; Hours since start of Date
-	S Y=SD#1-SB*100 ;SD#1=FM Time portion; -SB minus start of day; conv to hrs
-	N ST  ; ??
-	; Y#1 -> Minutes; *SI -> * Slots per hour; \.6 trunc min to hour
-	; Y\1 -> Hours since start of day; * SI: * slots
-	S ST=Y#1*SI\.6+(Y\1*SI)
-	N SS ; how many slots are supposed to be taken by appointment
-	S SS=SL*HSI/60 ; (nb: try SL: 30 min; HSI: 4 slots)
-	N I
-	I Y'<1 D  ; If Hours since start of Date is greater than 1
-	. ; loop through pattern. Tired of documenting.
-	. F I=ST+ST:SDDIF D  Q:Y=""  Q:SS'>0
-	. . S Y=$E(STR,$F(STR,$E(S,I+1))) Q:Y=""
-	. . S S=$E(S,1,I)_Y_$E(S,I+2,999)
-	. . S SS=SS-1
-	. . Q:SS'>0
-	S ^SC(BSDXSCD,"ST",SD\1,1)=S  ; new pattern; global set
 	Q
 	;
@@ -254,4 +201,6 @@
 	;
 ERR(BSDXI,BSDXERR)	;Error processing
+	; If last line is $C(31), we are done. No more errors to send to client.
+	I ^BSDXTMP($J,$O(^BSDXTMP($J," "),-1))=$C(31) QUIT
 	S BSDXI=BSDXI+1
 	S BSDXERR=$TR(BSDXERR,"^","~")
@@ -265,7 +214,7 @@
 	N $ET S $ET="D ^%ZTER HALT"  ; Emergency Error Trap
 	D ^%ZTER
-	S $EC=""  ; Clear Error
 	; Roll back BSDXAPPT; 
-	; TODO: What if a Mumps error happens in fileman in BSDXAPI? The Scheduling files can potentially be out of sync
+	; NB: What if a Mumps error happens inside fileman in BSDXAPI? 
+	; I have decided the M errors are out of scope for me to handle.
 	D:$G(BSDXAPTID) ROLLBACK(BSDXAPTID)
 	; Log error message and send to client
