Changeset 1071 for Scheduling
- Timestamp:
- Jan 19, 2011, 9:02:59 AM (14 years ago)
- Location:
- Scheduling/trunk/cs/bsdx0200GUISourceCode
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs
r1070 r1071 10 10 namespace IndianHealthService.ClinicalScheduling 11 11 { 12 /// <summary> 13 /// Contains the array of appointments and availabily that make up the document class 14 /// </summary> 15 public class CGDocument : System.Object 16 { 17 18 public CGDocument() 19 { 20 m_appointments = new CGAppointments(); 21 m_pAvArray = new ArrayList(); 22 m_sResourcesArray = new ArrayList(); 23 } 24 25 #region Member Variables 26 public int m_nColumnCount; //todo: this should point to the view's member for column count 27 public int m_nTimeUnits; 28 private string m_sDocName; 29 public ArrayList m_sResourcesArray; //keeps the resources 30 public ScheduleType m_ScheduleType; 31 private DateTime m_dSelectedDate; //Holds the user's selection from the dtpicker 32 private DateTime m_dStartDate; //Beginning date of document data 33 private DateTime m_dEndDate; //Ending date of document data 34 public CGAppointments m_appointments; 35 private ArrayList m_pAvArray; 36 private CGDocumentManager m_DocManager; 37 private DateTime m_dLastRefresh = DateTime.Now; 38 39 #endregion 40 41 #region Properties 42 43 /// <summary> 44 /// Returns the latest refresh time for this document 45 /// </summary> 46 public DateTime LastRefreshed 47 { 48 get 49 { 50 return m_dLastRefresh; 51 } 52 } 53 54 /// <summary> 55 /// The list of Resource names 56 /// </summary> 57 public ArrayList Resources 58 { 59 get 60 { 61 return this.m_sResourcesArray; 62 } 63 set 64 { 65 this.m_sResourcesArray = value; 66 } 67 } 68 69 /// <summary> 70 /// The array of CGAvailabilities that contains appt type and slots 71 /// </summary> 72 public ArrayList AvailabilityArray 73 { 74 get 75 { 76 return this.m_pAvArray; 77 } 78 } 79 80 public CGDocumentManager DocManager 81 { 82 get 83 { 84 return m_DocManager; 85 } 86 set 87 { 88 m_DocManager = value; 89 } 90 } 91 92 /// <summary> 93 /// Contains the hashtable of appointments 94 /// </summary> 95 public CGAppointments Appointments 96 { 97 get 98 { 99 return m_appointments; 100 } 101 } 102 103 /// <summary> 104 /// Holds the date selected by the user in CGView.dateTimePicker1 105 /// </summary> 106 public DateTime SelectedDate 107 { 108 get 109 { 110 return this.m_dSelectedDate; 111 } 112 set 113 { 114 this.m_dSelectedDate = value; 115 } 116 } 117 118 /// <summary> 119 /// Contains the beginning date of the appointment document 120 /// </summary> 121 public DateTime StartDate 122 { 123 get 124 { 125 return this.m_dStartDate; 126 } 127 } 128 129 public string DocName 130 { 131 get 132 { 133 return this.m_sDocName; 134 } 135 set 136 { 137 this.m_sDocName = value; 138 } 139 } 140 141 #endregion 142 143 #region Methods 144 145 public void UpdateAllViews() 146 { 147 //iterate through all views and call update. 148 Hashtable h = CGDocumentManager.Current.Views; 149 150 CGDocument d; 151 foreach (CGView v in h.Keys) 152 { 153 d = (CGDocument) h[v]; 154 if (d == this) 155 { 156 v.UpdateArrays(); 157 } 158 } 159 160 } 161 162 /// <summary> 163 /// Update schedule based on info in RPMS 164 /// </summary> 165 private bool RefreshDaysSchedule() 166 { 167 try 168 { 169 string sPatientName; 170 string sPatientID; 171 DateTime dStart; 172 DateTime dEnd; 173 DateTime dCheckIn; 174 DateTime dAuxTime; 175 int nKeyID; 176 string sNote; 177 string sResource; 178 bool bNoShow = false; 179 string sNoShow = "0"; 180 string sHRN = ""; 181 int nAccessTypeID; //used in autorebook 182 string sWalkIn = "0"; 183 bool bWalkIn; 184 CGAppointment pAppointment; 185 CGDocumentManager pApp = CGDocumentManager.Current; 186 DataTable rAppointmentSchedule; 12 /// <summary> 13 /// Contains the array of appointments and availabily that make up the document class 14 /// </summary> 15 public class CGDocument 16 { 17 #region Member Variables 18 public int m_nColumnCount; //todo: this should point to the view's member for column count 19 public int m_nTimeUnits; //? 20 private string m_sDocName; //Document Name ? 21 public ArrayList m_sResourcesArray; //keeps the resources 22 public ScheduleType m_ScheduleType; //Either a Resource or a Clinic (Group of Resources) 23 private DateTime m_dSelectedDate; //Holds the user's selection from the dtpicker 24 private DateTime m_dStartDate; //Beginning date of document data 25 private DateTime m_dEndDate; //Ending date of document data 26 public CGAppointments m_appointments; //Appointment List 27 private ArrayList m_pAvArray; //Availability List 28 private CGDocumentManager m_DocManager; //Holds a reference to the document manager 29 private DateTime m_dLastRefresh = DateTime.Now; //Holds last refersh date 30 #endregion 31 32 /// <summary> 33 /// Constructor. Initialize State Data: 34 /// 3 Arrays (Appointments, Availabilities, and Resources) 35 /// Schedule Type is Resource not Clinic 36 /// Selected Date is Today 37 /// Start Date is Today 38 /// End Date is 7 days from Today 39 /// </summary> 40 public CGDocument() 41 { 42 m_appointments = new CGAppointments(); // Holds Appointments 43 m_pAvArray = new ArrayList(); // Holds Availabilites 44 m_sResourcesArray = new ArrayList(); // Holds Resources 45 m_ScheduleType = ScheduleType.Resource; // Default Schedule Type is a Resource 46 m_dSelectedDate = DateTime.Today; // Default Selected Date is Today 47 m_dStartDate = DateTime.Today; // Default Start Date is Today 48 m_dEndDate = DateTime.Today.AddDays(7); // Default End Date is 7 days from Today. 49 } 50 51 52 #region Properties 53 54 /// <summary> 55 /// Returns the latest refresh time for this document 56 /// </summary> 57 public DateTime LastRefreshed 58 { 59 get 60 { 61 return m_dLastRefresh; 62 } 63 } 64 65 /// <summary> 66 /// The list of Resource names 67 /// </summary> 68 public ArrayList Resources 69 { 70 get 71 { 72 return this.m_sResourcesArray; 73 } 74 set 75 { 76 this.m_sResourcesArray = value; 77 } 78 } 79 80 /// <summary> 81 /// The array of CGAvailabilities that contains appt type and slots 82 /// </summary> 83 public ArrayList AvailabilityArray 84 { 85 get 86 { 87 return this.m_pAvArray; 88 } 89 } 90 91 public CGDocumentManager DocManager 92 { 93 get 94 { 95 return m_DocManager; 96 } 97 set 98 { 99 m_DocManager = value; 100 } 101 } 102 103 /// <summary> 104 /// Contains the hashtable of appointments 105 /// </summary> 106 public CGAppointments Appointments 107 { 108 get 109 { 110 return m_appointments; 111 } 112 } 113 114 /// <summary> 115 /// Holds the date selected by the user in CGView.dateTimePicker1 116 /// </summary> 117 public DateTime SelectedDate 118 { 119 get 120 { 121 return this.m_dSelectedDate; 122 } 123 set 124 { 125 this.m_dSelectedDate = value; 126 } 127 } 128 129 /// <summary> 130 /// Contains the beginning date of the appointment document 131 /// </summary> 132 public DateTime StartDate 133 { 134 get 135 { 136 return this.m_dStartDate; 137 } 138 } 139 140 public string DocName 141 { 142 get 143 { 144 return this.m_sDocName; 145 } 146 set 147 { 148 this.m_sDocName = value; 149 } 150 } 151 152 #endregion 153 154 #region Methods 155 156 public void UpdateAllViews() 157 { 158 //iterate through all views and call update. 159 Hashtable h = CGDocumentManager.Current.Views; 160 161 CGDocument d; 162 foreach (CGView v in h.Keys) 163 { 164 d = (CGDocument)h[v]; 165 if (d == this) 166 { 167 v.UpdateArrays(); 168 } 169 } 170 171 } 172 173 /// <summary> 174 /// Update schedule based on info in RPMS 175 /// </summary> 176 private bool RefreshDaysSchedule() 177 { 178 try 179 { 180 string sPatientName; 181 string sPatientID; 182 DateTime dStart; 183 DateTime dEnd; 184 DateTime dCheckIn; 185 DateTime dAuxTime; 186 int nKeyID; 187 string sNote; 188 string sResource; 189 bool bNoShow = false; 190 string sNoShow = "0"; 191 string sHRN = ""; 192 int nAccessTypeID; //used in autorebook 193 string sWalkIn = "0"; 194 bool bWalkIn; 195 CGAppointment pAppointment; 196 CGDocumentManager pApp = CGDocumentManager.Current; 197 DataTable rAppointmentSchedule; 187 198 188 199 //Nice to know that it gets set here!!! 189 190 191 200 m_dLastRefresh = DateTime.Now; 201 202 this.m_appointments.ClearAllAppointments(); 192 203 193 204 // calls RPC to get appointments 194 195 205 rAppointmentSchedule = CGSchedLib.CreateAppointmentSchedule(m_DocManager, m_sResourcesArray, this.m_dStartDate, this.m_dEndDate); 206 196 207 // Datatable dumper into Debug Log (nice to know that this exists) 197 208 CGSchedLib.OutputArray(rAppointmentSchedule, "rAppointmentSchedule"); 198 199 200 foreach (DataRow r in rAppointmentSchedule.Rows) 201 { 202 203 if (r["APPOINTMENTID"].ToString() == "0") 204 { 205 string sMsg = r["NOTE"].ToString(); 206 throw new BMXNetException(sMsg); 207 } 208 nKeyID = Convert.ToInt32(r["APPOINTMENTID"].ToString()); 209 sResource = r["RESOURCENAME"].ToString(); 210 sPatientName =r["PATIENTNAME"].ToString(); 211 sPatientID =r["PATIENTID"].ToString(); 212 dStart = (DateTime) r["START_TIME"]; 213 dEnd = (DateTime) r["END_TIME"]; 214 dCheckIn = new DateTime(); 215 dAuxTime = new DateTime(); 216 217 if (r["CHECKIN"].GetType() != typeof(System.DBNull)) 218 dCheckIn = (DateTime) r["CHECKIN"]; 219 if (r["AUXTIME"].GetType() != typeof(System.DBNull)) 220 dCheckIn = (DateTime) r["AUXTIME"]; 221 sNote = r["NOTE"].ToString(); 222 sNoShow = r["NOSHOW"].ToString(); 223 bNoShow = (sNoShow == "1")?true: false; 224 sHRN = r["HRN"].ToString(); 225 nAccessTypeID = (int) r["ACCESSTYPEID"]; 226 sWalkIn = r["WALKIN"].ToString(); 227 bWalkIn = (sWalkIn == "1")?true: false; 228 229 pAppointment = new CGAppointment(); 230 pAppointment.CreateAppointment(dStart, dEnd, sNote, nKeyID, sResource); 231 pAppointment.PatientName = sPatientName; 232 pAppointment.PatientID = Convert.ToInt32(sPatientID); 233 if (dCheckIn.Ticks > 0) 234 pAppointment.CheckInTime = dCheckIn; 235 if (dAuxTime.Ticks > 0) 236 pAppointment.AuxTime = dAuxTime; 237 pAppointment.NoShow = bNoShow; 238 pAppointment.HealthRecordNumber = sHRN; 239 pAppointment.AccessTypeID = nAccessTypeID; 240 pAppointment.WalkIn = bWalkIn; 241 this.m_appointments.AddAppointment(pAppointment); 242 243 } 244 245 return true; 246 } 247 catch(Exception Ex) 248 { 249 Debug.Write("CGDocument.RefreshDaysSchedule error: " + Ex.Message + "\n"); 250 return false; 251 } 252 } 253 254 255 public void OnNewDocument() 256 { 257 /* 258 * TEST EXCEPTION -- REMOVE AFTER TESTING 259 */ 260 // throw new Exception("Simulated Uncaught Exception"); 261 /* 262 * TEST EXCEPTION -- REMOVE AFTER TESTING 263 */ 264 265 //Open an empty document 266 m_sResourcesArray.Clear(); 267 m_ScheduleType = ScheduleType.Resource; 268 269 //Set initial From and To dates based on current day 270 // DateTime dDate = new DateTime(2001,12,05); //Testing line 271 DateTime dDate = DateTime.Today; 272 273 //smh: Question: Where does bRet get used? It's a useless varaible so far. 274 bool bRet = this.WeekNeedsRefresh(2,dDate, out this.m_dStartDate, out this.m_dEndDate); 275 276 //Create new View 277 CGView view = new CGView(); 278 view.InitializeDocView(this, 279 this.DocManager, 280 m_dStartDate, 281 this.Appointments, 282 DocManager.WindowText); 283 284 view.Show(); 285 view.SyncTree(); 286 view.Activate(); 287 this.UpdateAllViews(); 288 } 289 290 public void RefreshDocument() 291 { 209 210 211 foreach (DataRow r in rAppointmentSchedule.Rows) 212 { 213 214 if (r["APPOINTMENTID"].ToString() == "0") 215 { 216 string sMsg = r["NOTE"].ToString(); 217 throw new BMXNetException(sMsg); 218 } 219 nKeyID = Convert.ToInt32(r["APPOINTMENTID"].ToString()); 220 sResource = r["RESOURCENAME"].ToString(); 221 sPatientName = r["PATIENTNAME"].ToString(); 222 sPatientID = r["PATIENTID"].ToString(); 223 dStart = (DateTime)r["START_TIME"]; 224 dEnd = (DateTime)r["END_TIME"]; 225 dCheckIn = new DateTime(); 226 dAuxTime = new DateTime(); 227 228 if (r["CHECKIN"].GetType() != typeof(System.DBNull)) 229 dCheckIn = (DateTime)r["CHECKIN"]; 230 if (r["AUXTIME"].GetType() != typeof(System.DBNull)) 231 dCheckIn = (DateTime)r["AUXTIME"]; 232 sNote = r["NOTE"].ToString(); 233 sNoShow = r["NOSHOW"].ToString(); 234 bNoShow = (sNoShow == "1") ? true : false; 235 sHRN = r["HRN"].ToString(); 236 nAccessTypeID = (int)r["ACCESSTYPEID"]; 237 sWalkIn = r["WALKIN"].ToString(); 238 bWalkIn = (sWalkIn == "1") ? true : false; 239 240 pAppointment = new CGAppointment(); 241 pAppointment.CreateAppointment(dStart, dEnd, sNote, nKeyID, sResource); 242 pAppointment.PatientName = sPatientName; 243 pAppointment.PatientID = Convert.ToInt32(sPatientID); 244 if (dCheckIn.Ticks > 0) 245 pAppointment.CheckInTime = dCheckIn; 246 if (dAuxTime.Ticks > 0) 247 pAppointment.AuxTime = dAuxTime; 248 pAppointment.NoShow = bNoShow; 249 pAppointment.HealthRecordNumber = sHRN; 250 pAppointment.AccessTypeID = nAccessTypeID; 251 pAppointment.WalkIn = bWalkIn; 252 this.m_appointments.AddAppointment(pAppointment); 253 254 } 255 256 return true; 257 } 258 catch (Exception Ex) 259 { 260 Debug.Write("CGDocument.RefreshDaysSchedule error: " + Ex.Message + "\n"); 261 return false; 262 } 263 } 264 265 266 public bool IsRefreshNeeded() 267 { 268 if (m_sResourcesArray.Count == 0) return false; 269 return this.WeekNeedsRefresh(1, m_dSelectedDate, out this.m_dStartDate, out this.m_dEndDate); 270 } 271 272 273 public void RefreshDocument() 274 { 292 275 bool bRet = false; 276 if (m_sResourcesArray.Count == 0) 277 return; 293 278 if (m_sResourcesArray.Count == 1) 294 279 { … … 304 289 } 305 290 306 307 308 309 310 public void OnOpenDocument() 311 312 313 314 315 m_ScheduleType = (m_sResourcesArray.Count == 1) ? ScheduleType.Resource: ScheduleType.Clinic;316 317 318 319 320 321 322 bRet = this.WeekNeedsRefresh(1,dDate, out this.m_dStartDate, out this.m_dEndDate);323 324 325 326 327 328 329 330 331 332 333 334 335 336 291 bRet = RefreshSchedule(); 292 this.UpdateAllViews(); 293 } 294 295 public void OnOpenDocument() 296 { 297 try 298 { 299 //Create new Document 300 m_ScheduleType = (m_sResourcesArray.Count == 1) ? ScheduleType.Resource : ScheduleType.Clinic; 301 bool bRet = false; 302 303 //Set initial From and To dates based on current day 304 DateTime dDate = DateTime.Today; 305 if (m_ScheduleType == ScheduleType.Resource) 306 { 307 bRet = this.WeekNeedsRefresh(1, dDate, out this.m_dStartDate, out this.m_dEndDate); 308 } 309 else 310 { 311 this.m_dStartDate = dDate; 312 this.m_dEndDate = dDate; 313 this.m_dEndDate = this.m_dEndDate.AddHours(23); 314 this.m_dEndDate = this.m_dEndDate.AddMinutes(59); 315 this.m_dEndDate = this.m_dEndDate.AddSeconds(59); 316 } 317 318 bRet = RefreshSchedule(); 319 320 CGView view = null; 321 //If this document already has a view, the use it 337 322 //SAM: Why do this again??? 338 Hashtable h = CGDocumentManager.Current.Views; 339 340 341 342 343 d = (CGDocument)h[v];344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 view.InitializeDocView(this, 359 360 m_dStartDate, 361 this.Appointments, 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 323 Hashtable h = CGDocumentManager.Current.Views; 324 CGDocument d; 325 bool bReuseView = false; 326 foreach (CGView v in h.Keys) 327 { 328 d = (CGDocument)h[v]; 329 if (d == this) 330 { 331 view = v; 332 bReuseView = true; 333 v.InitializeDocView(this.DocName); 334 break; 335 } 336 } 337 338 //Otherwise, create new View 339 if (bReuseView == false) 340 { 341 view = new CGView(); 342 343 view.InitializeDocView(this, 344 this.DocManager, 345 m_dStartDate, 346 this.Appointments, 347 this.DocName); 348 349 view.Show(); 350 view.SyncTree(); 351 352 } 353 this.UpdateAllViews(); 354 } 355 catch (BMXNetException bmxEx) 356 { 357 throw bmxEx; 358 } 359 catch (Exception ex) 360 { 361 throw new BMXNet.BMXNetException("ClinicalScheduling.OnOpenDocument error: " + ex.Message); 362 } 363 } 379 364 380 365 /// <summary> … … 382 367 /// </summary> 383 368 /// <returns>Success or Failure. Should be always Success.</returns> 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 DataTable rTypeSchedule = new DataTable();;430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 Rectangle crRectA = new Rectangle(0,0,1,0);452 Rectangle crRectB= new Rectangle(0,0,1,0);453 boolbIsect;454 455 456 457 458 459 460 461 dStart = (DateTime)rTemp["START_TIME"];462 dEnd = (DateTime)rTemp["END_TIME"];463 464 465 466 467 468 469 470 471 472 473 if ((nSlots < -1000)||(sAccessRuleList == ""))474 475 476 477 else 478 479 480 481 482 dTypeStart = (DateTime)rType["StartTime"];483 dTypeEnd = (DateTime)rType["EndTime"];484 485 486 if ((dTypeStart.DayOfYear == dStart.DayOfYear)&& (sResourceList == sTypeResource))487 488 489 490 491 492 493 if (bIsect == true) 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 sTemp = (sTemp == "")?"0":sTemp;543 544 545 546 sTemp = (sTemp == "")?"0":sTemp;547 548 549 550 sTemp = (sTemp == "")?"0":sTemp;551 552 553 554 555 556 557 558 559 560 if (UpdateView == true) 561 562 563 564 return nIndex; 565 566 567 568 569 570 571 369 private bool RefreshSchedule() 370 { 371 try 372 { 373 bool bRet = this.RefreshAvailabilitySchedule(); 374 if (bRet == false) 375 { 376 return bRet; 377 } 378 bRet = this.RefreshDaysSchedule(); 379 return bRet; 380 } 381 catch (ApplicationException aex) 382 { 383 Debug.Write("CGDocument.RefreshSchedule Application Error: " + aex.Message + "\n"); 384 return false; 385 } 386 catch (Exception ex) 387 { 388 MessageBox.Show("CGDocument.RefreshSchedule error: " + ex.Message + "\n"); 389 return false; 390 } 391 } 392 393 private bool RefreshAvailabilitySchedule() 394 { 395 try 396 { 397 if (this.m_DocManager.ConnectInfo.Connected == false) 398 { 399 m_DocManager.ConnectInfo.LoadConnectInfo(); 400 } 401 402 m_pAvArray.Clear(); 403 404 ArrayList saryApptTypes = new ArrayList(); 405 int nApptTypeID = 0; 406 407 //Refresh Availability schedules 408 DataTable rAvailabilitySchedule; 409 rAvailabilitySchedule = CGSchedLib.CreateAvailabilitySchedule(m_DocManager, m_sResourcesArray, this.m_dStartDate, this.m_dEndDate, saryApptTypes,/**/ m_ScheduleType, "0"); 410 CGSchedLib.OutputArray(rAvailabilitySchedule, "rAvailabilitySchedule"); 411 412 //Refresh Type Schedule 413 string sResourceName = ""; 414 DataTable rTypeSchedule = new DataTable(); ; 415 for (int j = 0; j < m_sResourcesArray.Count; j++) 416 { 417 sResourceName = m_sResourcesArray[j].ToString(); 418 DataTable dtTemp = CGSchedLib.CreateAssignedTypeSchedule(m_DocManager, sResourceName, this.m_dStartDate, this.m_dEndDate, m_ScheduleType); 419 CGSchedLib.OutputArray(dtTemp, "dtTemp"); 420 if (j == 0) 421 { 422 rTypeSchedule = dtTemp; 423 } 424 else 425 { 426 rTypeSchedule = CGSchedLib.UnionBlocks(rTypeSchedule, dtTemp); 427 } 428 } 429 CGSchedLib.OutputArray(rTypeSchedule, "rTypeSchedule"); 430 431 DateTime dStart; 432 DateTime dEnd; 433 DateTime dTypeStart; 434 DateTime dTypeEnd; 435 int nSlots; 436 Rectangle crRectA = new Rectangle(0, 0, 1, 0); 437 Rectangle crRectB = new Rectangle(0, 0, 1, 0); 438 bool bIsect; 439 string sResourceList; 440 string sAccessRuleList; 441 442 443 foreach (DataRow rTemp in rAvailabilitySchedule.Rows) 444 { 445 //get StartTime, EndTime and Slots 446 dStart = (DateTime)rTemp["START_TIME"]; 447 dEnd = (DateTime)rTemp["END_TIME"]; 448 449 //TODO: Fix this slots datatype problem 450 string sSlots = rTemp["SLOTS"].ToString(); 451 nSlots = Convert.ToInt16(sSlots); 452 453 sResourceList = rTemp["RESOURCE"].ToString(); 454 sAccessRuleList = rTemp["ACCESS_TYPE"].ToString(); 455 456 string sNote = rTemp["NOTE"].ToString(); 457 458 if ((nSlots < -1000) || (sAccessRuleList == "")) 459 { 460 nApptTypeID = 0; 461 } 462 else 463 { 464 foreach (DataRow rType in rTypeSchedule.Rows) 465 { 466 467 dTypeStart = (DateTime)rType["StartTime"]; 468 dTypeEnd = (DateTime)rType["EndTime"]; 469 //if start & end times overlap, then 470 string sTypeResource = rType["ResourceName"].ToString(); 471 if ((dTypeStart.DayOfYear == dStart.DayOfYear) && (sResourceList == sTypeResource)) 472 { 473 crRectA.Y = GetTotalMinutes(dStart); 474 crRectA.Height = GetTotalMinutes(dEnd) - crRectA.Top; 475 crRectB.Y = GetTotalMinutes(dTypeStart); 476 crRectB.Height = GetTotalMinutes(dTypeEnd) - crRectB.Top; 477 bIsect = crRectA.IntersectsWith(crRectB); 478 if (bIsect == true) 479 { 480 //TODO: This code: 481 // nApptTypeID = (int) rType["AppointmentTypeID"]; 482 //Causes this exception: 483 //Unhandled Exception: System.InvalidCastException: Specified cast is not valid. 484 string sTemp = rType["AppointmentTypeID"].ToString(); 485 nApptTypeID = Convert.ToInt16(sTemp); 486 break; 487 } 488 } 489 }//end foreach datarow rType 490 } 491 492 AddAvailability(dStart, dEnd, nApptTypeID, nSlots, false, sResourceList, sAccessRuleList, sNote); 493 }//end foreach datarow rTemp 494 495 return true; 496 } 497 catch (Exception ex) 498 { 499 Debug.Write("CGDocument.RefreshAvailabilitySchedule error: " + ex.Message + "\n"); 500 return false; 501 } 502 } 503 504 private int GetTotalMinutes(DateTime dDate) 505 { 506 return ((dDate.Hour * 60) + dDate.Minute); 507 } 508 509 public int AddAvailability(DateTime StartTime, DateTime EndTime, int nType, int nSlots, bool UpdateView, string sResourceList, string sAccessRuleList, string sNote) 510 { 511 //adds it to the object array 512 //Returns the index in the array 513 514 CGAvailability pNewAv = new CGAvailability(); 515 pNewAv.Create(StartTime, EndTime, nType, nSlots, sResourceList, sAccessRuleList); 516 517 pNewAv.Note = sNote; 518 519 //Look up the color and type name using the AppointmentTypes datatable 520 DataTable dtType = this.m_DocManager.GlobalDataSet.Tables["AccessTypes"]; 521 DataRow dRow = dtType.Rows.Find(nType.ToString()); 522 if (dRow != null) 523 { 524 string sColor = dRow["DISPLAY_COLOR"].ToString(); 525 pNewAv.DisplayColor = sColor; 526 string sTemp = dRow["RED"].ToString(); 527 sTemp = (sTemp == "") ? "0" : sTemp; 528 int nRed = Convert.ToInt16(sTemp); 529 pNewAv.Red = nRed; 530 sTemp = dRow["GREEN"].ToString(); 531 sTemp = (sTemp == "") ? "0" : sTemp; 532 int nGreen = Convert.ToInt16(sTemp); 533 pNewAv.Green = nGreen; 534 sTemp = dRow["BLUE"].ToString(); 535 sTemp = (sTemp == "") ? "0" : sTemp; 536 int nBlue = Convert.ToInt16(sTemp); 537 pNewAv.Blue = nBlue; 538 539 string sName = dRow["ACCESS_TYPE_NAME"].ToString(); 540 pNewAv.AccessTypeName = sName; 541 } 542 543 int nIndex = 0; 544 nIndex = m_pAvArray.Add(pNewAv); 545 if (UpdateView == true) 546 { 547 this.UpdateAllViews(); 548 } 549 return nIndex; 550 } 551 552 553 public void AddResource(string sResource) 554 { 555 //TODO: Test that resource is not currently in list, that it IS a resource, etc 556 this.m_sResourcesArray.Add(sResource); 572 557 //SAM: removing: Remove UpdateAllViews: Redraws all the open views. But does not call server. 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 Rectangle crRectA = new Rectangle(0,0,1,0);592 Rectangle crRectB = new Rectangle(0,0,1,0);593 594 595 crRectB.Height = GetTotalMinutes(dSelEnd)- crRectB.Y;596 597 598 599 while (i < m_pAvArray.Count) 600 601 pAv = (CGAvailability)m_pAvArray[i];602 603 604 if ((sResource == pAv.ResourceList) && 605 606 607 608 609 610 611 if (bIsect != false) 612 613 614 if (nSlots < 1) 615 616 617 618 619 if (nSlots < nAvailableSlots) 620 621 622 623 624 625 626 627 628 629 630 if (nAvailableSlots == 999) 631 632 633 634 635 } 636 637 638 639 640 641 558 //this.UpdateAllViews(); 559 } 560 561 public void ClearResources() 562 { 563 this.m_sResourcesArray.Clear(); 564 } 565 566 public int SlotsAvailable(DateTime dSelStart, DateTime dSelEnd, string sResource, out string sAccessType, out string sAvailabilityMessage) 567 { 568 sAccessType = ""; 569 sAvailabilityMessage = ""; 570 DateTime dStart; 571 DateTime dEnd; 572 int nAvailableSlots = 999; 573 int nSlots = 0; 574 int i = 0; 575 CGAvailability pAv; 576 Rectangle crRectA = new Rectangle(0, 0, 1, 0); 577 Rectangle crRectB = new Rectangle(0, 0, 1, 0); 578 bool bIsect; 579 crRectB.Y = GetTotalMinutes(dSelStart); 580 crRectB.Height = GetTotalMinutes(dSelEnd) - crRectB.Y; 581 582 // //loop thru m_pAvArray 583 // //Compare the start time and end time of eachblock 584 while (i < m_pAvArray.Count) 585 { 586 pAv = (CGAvailability)m_pAvArray[i]; 587 dStart = pAv.StartTime; 588 dEnd = pAv.EndTime; 589 if ((sResource == pAv.ResourceList) && 590 ((dSelStart.Date == dStart.Date) || (dSelStart.Date == dEnd.Date))) 591 { 592 crRectA.Y = (dStart.Date < dSelStart.Date) ? 0 : GetTotalMinutes(dStart); 593 crRectA.Height = (dEnd.Date > dSelEnd.Date) ? 1440 : GetTotalMinutes(dEnd); 594 crRectA.Height = crRectA.Height - crRectA.Y; 595 bIsect = crRectA.IntersectsWith(crRectB); 596 if (bIsect != false) 597 { 598 nSlots = pAv.Slots; 599 if (nSlots < 1) 600 { 601 nAvailableSlots = 0; 602 break; 603 } 604 if (nSlots < nAvailableSlots) 605 { 606 nAvailableSlots = nSlots; 607 sAccessType = pAv.AccessTypeName; 608 sAvailabilityMessage = pAv.Note; 609 610 } 611 } 612 } 613 i++; 614 } 615 if (nAvailableSlots == 999) 616 { 617 nAvailableSlots = 0; 618 } 619 return nAvailableSlots; 620 } 621 622 /// <summary> 623 /// Given a selected date, 624 /// Calculates StartDay and End Day and returns them in output params. 625 /// nWeeks == number of Weeks to display 626 /// nColumnCount is number of days displayed per week. 642 627 /// If 5 columns, begin on Second Day of Week 643 628 /// If 7 Columns, begin on First Day of Week 644 629 /// (this is a change from the hardcoded behavior for US-based calendars) 645 646 647 648 649 public bool WeekNeedsRefresh(int nWeeks, DateTime SelectedDate, 650 651 652 653 630 /// 631 /// Returns TRUE if the document's data needs refreshing based on 632 /// this newly selected date. 633 /// </summary> 634 public bool WeekNeedsRefresh(int nWeeks, DateTime SelectedDate, 635 out DateTime WeekStartDay, out DateTime WeekEndDay) 636 { 637 DateTime OldStartDay = m_dStartDate; 638 DateTime OldEndDay = m_dEndDate; 654 639 // Week start based on thread locale 655 640 int nStartWeekDay = (int)System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.FirstDayOfWeek; 656 641 // Current Day 657 int nWeekDay = (int) 658 659 642 int nWeekDay = (int)SelectedDate.DayOfWeek; //0 == Sunday 643 644 // this offset gets approrpriate day based on locale. 660 645 int nOff = (nStartWeekDay + 1) % 7; 661 TimeSpan ts = new TimeSpan(nWeekDay - nOff,0,0,0); //d,h,m,s646 TimeSpan ts = new TimeSpan(nWeekDay - nOff, 0, 0, 0); //d,h,m,s 662 647 663 648 // if ts is negative, we will jump to the next week in the logic. 664 649 // to show the correct week, add 7. Confusing, I know. 665 if (ts < new TimeSpan() ) ts = ts + new TimeSpan(7,0,0,0);666 667 668 669 ts = new TimeSpan(0,23,59,59);670 650 if (ts < new TimeSpan()) ts = ts + new TimeSpan(7, 0, 0, 0); 651 652 if (m_nColumnCount == 1) // if one column start and end on the same day. 653 { 654 ts = new TimeSpan(0, 23, 59, 59); 655 WeekStartDay = SelectedDate; 671 656 WeekEndDay = WeekStartDay + ts; 672 657 } 673 658 else if (m_nColumnCount == 5 || m_nColumnCount == 0) // if 5 column start (or default) at the 2nd day of this week and end in 4:23:59:59 days. 674 659 { 675 660 // if picked day is start of week (Sunday in US), start in the next day since that's the first day of work week 676 661 // else, just substract the calculated time span to get to the start of week (first work day) 677 WeekStartDay = (nWeekDay == nStartWeekDay) ? SelectedDate + new TimeSpan(1, 0,0,0): SelectedDate - ts;662 WeekStartDay = (nWeekDay == nStartWeekDay) ? SelectedDate + new TimeSpan(1, 0, 0, 0) : SelectedDate - ts; 678 663 // End day calculation 679 664 int nEnd = 3; … … 684 669 { 685 670 // if picked day is start of week, use that. Otherwise, go to the fist work day and substract one to get to start of week. 686 WeekStartDay = (nWeekDay == nStartWeekDay) ? SelectedDate : SelectedDate - ts - new TimeSpan(1, 0,0,0);671 WeekStartDay = (nWeekDay == nStartWeekDay) ? SelectedDate : SelectedDate - ts - new TimeSpan(1, 0, 0, 0); 687 672 // End day calculation 688 673 int nEnd = 1; … … 691 676 } 692 677 693 bool bRet = ((WeekStartDay.Date != OldStartDay.Date) || (WeekEndDay.Date != OldEndDay.Date));694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 678 bool bRet = ((WeekStartDay.Date != OldStartDay.Date) || (WeekEndDay.Date != OldEndDay.Date)); 679 return bRet; 680 } 681 682 /// <summary> 683 /// Calls RPMS to create appointment then 684 /// adds appointment to the m_appointments collection 685 /// Returns the IEN of the appointment in the RPMS BSDX APPOINTMENT file. 686 /// </summary> 687 /// <param name="rApptInfo"></param> 688 /// <returns></returns> 689 public int CreateAppointment(CGAppointment rApptInfo) 690 { 691 return CreateAppointment(rApptInfo, false); 692 } 693 694 /// <summary> 695 /// Use this overload to create a walkin appointment 696 /// </summary> 697 /// <param name="rApptInfo"></param> 698 /// <param name="bWalkin"></param> 699 /// <returns></returns> 700 public int CreateAppointment(CGAppointment rApptInfo, bool bWalkin) 701 { 702 string sStart; 703 string sEnd; 704 string sPatID; 705 string sResource; 706 string sNote; 707 string sLen; 708 string sApptID; 709 710 //sStart = rApptInfo.StartTime.ToString("M-d-yyyy@HH:mm"); 711 //sEnd = rApptInfo.EndTime.ToString("M-d-yyyy@HH:mm"); 727 712 728 713 // i18n code -- Use culture neutral FMDates … … 730 715 sEnd = FMDateTime.Create(rApptInfo.EndTime).FMDateString; 731 716 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 string sSql = "BSDX ADD NEW APPOINTMENT^" + sStart + "^" + sEnd + "^" + sPatID + "^" + sResource + "^" + sLen + "^" + sNote + "^" + sApptID;754 755 756 757 758 759 nApptID =Convert.ToInt32(r["APPOINTMENTID"]);760 761 762 if ((sErrorID != "")||(nApptID < 1))763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 717 TimeSpan sp = rApptInfo.EndTime - rApptInfo.StartTime; 718 sLen = sp.TotalMinutes.ToString(); 719 sPatID = rApptInfo.PatientID.ToString(); 720 sNote = rApptInfo.Note; 721 sResource = rApptInfo.Resource; 722 if (bWalkin == true) 723 { 724 sApptID = "WALKIN"; 725 } 726 else 727 { 728 sApptID = rApptInfo.AccessTypeID.ToString(); 729 } 730 731 CGAppointment aCopy = new CGAppointment(); 732 aCopy.CreateAppointment(rApptInfo.StartTime, rApptInfo.EndTime, sNote, 0, sResource); 733 aCopy.PatientID = rApptInfo.PatientID; 734 aCopy.PatientName = rApptInfo.PatientName; 735 aCopy.HealthRecordNumber = rApptInfo.HealthRecordNumber; 736 aCopy.AccessTypeID = rApptInfo.AccessTypeID; 737 738 string sSql = "BSDX ADD NEW APPOINTMENT^" + sStart + "^" + sEnd + "^" + sPatID + "^" + sResource + "^" + sLen + "^" + sNote + "^" + sApptID; 739 System.Data.DataTable dtAppt = m_DocManager.RPMSDataTable(sSql, "NewAppointment"); 740 int nApptID; 741 742 Debug.Assert(dtAppt.Rows.Count == 1); 743 DataRow r = dtAppt.Rows[0]; 744 nApptID = Convert.ToInt32(r["APPOINTMENTID"]); 745 string sErrorID; 746 sErrorID = r["ERRORID"].ToString(); 747 if ((sErrorID != "") || (nApptID < 1)) 748 throw new Exception(sErrorID); 749 aCopy.AppointmentKey = nApptID; 750 this.m_appointments.AddAppointment(aCopy); 751 752 bool bRet = RefreshAvailabilitySchedule(); 753 754 UpdateAllViews(); 755 756 return nApptID; 757 } 758 759 public void EditAppointment(CGAppointment pAppt, string sNote) 760 { 761 try 762 { 763 int nApptID = pAppt.AppointmentKey; 764 string sSql = "BSDX EDIT APPOINTMENT^" + nApptID.ToString() + "^" + sNote; 765 766 System.Data.DataTable dtAppt = m_DocManager.RPMSDataTable(sSql, "EditAppointment"); 767 768 Debug.Assert(dtAppt.Rows.Count == 1); 769 DataRow r = dtAppt.Rows[0]; 770 string sErrorID = r["ERRORID"].ToString(); 771 if (sErrorID == "-1") 772 pAppt.Note = sNote; 773 774 if (this.m_appointments.AppointmentTable.ContainsKey(nApptID)) 775 { 776 bool bRet = RefreshAvailabilitySchedule(); 777 UpdateAllViews(); 778 } 779 } 780 catch (Exception ex) 781 { 782 Debug.Write("CGDocument.EditAppointment Failed: " + ex.Message); 783 } 784 } 785 786 public void CheckInAppointment(int nApptID, DateTime dCheckIn) 787 { 788 string sCheckIn = FMDateTime.Create(dCheckIn).FMDateString; 804 789 805 790 string sSql = "BSDX CHECKIN APPOINTMENT^" + nApptID.ToString() + "^" + sCheckIn; // +"^"; 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 string sClinicCancelled = (bClinicCancelled == true)?"C":"PC";833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 int nIncrement = (nMaximumDays < 30)?nMaximumDays:30;907 908 909 910 911 912 913 914 791 //sSql += ClinicStopIEN + "^" + ProviderIEN + "^" + PrintRouteSlip + "^"; 792 //sSql += PCCClinicIEN + "^" + PCCFormIEN + "^" + PCCOutGuide; 793 794 System.Data.DataTable dtAppt = m_DocManager.RPMSDataTable(sSql, "CheckInAppointment"); 795 796 Debug.Assert(dtAppt.Rows.Count == 1); 797 DataRow r = dtAppt.Rows[0]; 798 string sErrorID = r["ERRORID"].ToString(); 799 800 if (this.m_appointments.AppointmentTable.ContainsKey(nApptID)) 801 { 802 bool bRet = RefreshSchedule(); 803 UpdateAllViews(); 804 } 805 } 806 807 public string DeleteAppointment(int nApptID) 808 { 809 return DeleteAppointment(nApptID, true, 0, ""); 810 } 811 812 public string DeleteAppointment(int nApptID, bool bClinicCancelled, int nReason, string sRemarks) 813 { 814 //Returns "" if deletion successful 815 //Otherwise, returns reason for failure 816 817 string sClinicCancelled = (bClinicCancelled == true) ? "C" : "PC"; 818 string sReasonID = nReason.ToString(); 819 string sSql = "BSDX CANCEL APPOINTMENT^" + nApptID.ToString(); 820 sSql += "^" + sClinicCancelled; 821 sSql += "^" + sReasonID; 822 sSql += "^" + sRemarks; 823 DataTable dtAppt = m_DocManager.RPMSDataTable(sSql, "DeleteAppointment"); 824 825 Debug.Assert(dtAppt.Rows.Count == 1); 826 DataRow r = dtAppt.Rows[0]; 827 string sErrorID = r["ERRORID"].ToString(); 828 if (sErrorID != "") 829 return sErrorID; 830 831 if (this.m_appointments.AppointmentTable.ContainsKey(nApptID)) 832 { 833 this.m_appointments.RemoveAppointment(nApptID); 834 bool bRet = RefreshAvailabilitySchedule(); 835 UpdateAllViews(); 836 } 837 return ""; 838 } 839 840 public string AutoRebook(CGAppointment a, int nSearchType, int nMinimumDays, int nMaximumDays, out CGAppointment aRebook) 841 { 842 //If successful Returns "1" and new start date and time returned in aRebook 843 //Otherwise, returns error message 844 845 CGAppointment aCopy = new CGAppointment(); 846 aCopy.CreateAppointment(a.StartTime, a.EndTime, a.Note, 0, a.Resource); 847 aCopy.PatientID = a.PatientID; 848 aCopy.PatientName = a.PatientName; 849 aCopy.HealthRecordNumber = a.HealthRecordNumber; 850 aCopy.AccessTypeID = a.AccessTypeID; 851 aRebook = aCopy; 852 853 //Determine Rebook access type 854 //nSearchType = -1: use current, -2: use any non-zero type, >0 use this access type id 855 int nAVType = 0; 856 857 switch (nSearchType) 858 { 859 case -1: 860 nAVType = a.AccessTypeID; 861 break; 862 case -2: 863 nAVType = 0; 864 break; 865 default: 866 nAVType = nSearchType; 867 break; 868 } 869 870 int nSlots = 0; 871 string sSlots = ""; 872 int nAccessTypeID; //To compare with nAVType 873 874 DateTime dResult = new DateTime(); //StartTime of access block to autorebook into 875 876 //Next two are empty, but needed to pass to CreateAvailabilitySchedule 877 ArrayList alAccessTypes = new ArrayList(); 878 string sSearchInfo = ""; 879 880 //Find the StartTime of first availability block of this type for this clinic 881 //between nMinimumDays and nMaximumDays 882 883 string sAVStart = a.StartTime.AddDays(nMinimumDays).ToString("M/d/yyyy@H:mm"); 884 885 //dtAVEnd is the last day to search 886 DateTime dtAVEnd = a.StartTime.AddDays(nMinimumDays + nMaximumDays); 887 string sAVEnd = dtAVEnd.ToString("M/d/yyyy@H:mm"); 888 889 //Increment start day to search a week (or so) at a time 890 //30 is a test increment. Need to test different values for performance 891 int nIncrement = (nMaximumDays < 30) ? nMaximumDays : 30; 892 893 //nCount and nCountEnd are the 'moving' counters 894 //that I add to start and end to get the bracket 895 //At the beginning of the DO loop, nCount and nCountEnd are already set 896 bool bFinished = false; 897 bool bFound = false; 898 899 DateTime dStart = a.StartTime.AddDays(nMinimumDays); 915 900 // v 1.3 i18n support - FM Date passed insated of American Date 916 901 string sStart = FMDateTime.Create(dStart).DateOnly.FMDateString; 917 918 919 { 920 921 922 923 924 925 926 927 928 929 DateTime dNextBlock = (DateTime)drNextBlockRow["NEXTBLOCK"];930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 if (dr["ACCESS_TYPE"].ToString() != "") 954 nAccessTypeID =Convert.ToInt16(dr["ACCESS_TYPE"].ToString());955 956 957 958 959 dResult = (DateTime)dr["START_TIME"];960 961 962 963 964 965 966 dResult = (DateTime)dr["START_TIME"];967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 902 DateTime dEnd = dStart.AddDays(nIncrement); 903 do 904 { 905 string sSql = "BSDX REBOOK NEXT BLOCK^" + sStart + "^" + a.Resource + "^" + nAVType.ToString(); 906 DataTable dtNextBlock = this.DocManager.RPMSDataTable(sSql, "NextBlock"); 907 Debug.Assert(dtNextBlock.Rows.Count == 1); 908 DataRow drNextBlockRow = dtNextBlock.Rows[0]; 909 910 object oNextBlock; 911 oNextBlock = drNextBlockRow["NEXTBLOCK"]; 912 if (oNextBlock.GetType() == typeof(System.DBNull)) 913 break; 914 DateTime dNextBlock = (DateTime)drNextBlockRow["NEXTBLOCK"]; 915 if (dNextBlock > dtAVEnd) 916 { 917 break; 918 } 919 920 dStart = dNextBlock; 921 dEnd = dStart.AddDays(nIncrement); 922 if (dEnd > dtAVEnd) 923 dEnd = dtAVEnd; 924 925 DataTable dtResult = CGSchedLib.CreateAvailabilitySchedule(m_DocManager, this.Resources, dStart, dEnd, alAccessTypes, ScheduleType.Resource, sSearchInfo); 926 //Loop thru dtResult looking for a slot having the required availability type. 927 //If found, set bFinished = true; 928 foreach (DataRow dr in dtResult.Rows) 929 { 930 931 sSlots = dr["SLOTS"].ToString(); 932 if (sSlots == "") 933 sSlots = "0"; 934 nSlots = Convert.ToInt16(sSlots); 935 if (nSlots > 0) 936 { 937 nAccessTypeID = 0; //holds the access type id of the availability block 938 if (dr["ACCESS_TYPE"].ToString() != "") 939 nAccessTypeID = Convert.ToInt16(dr["ACCESS_TYPE"].ToString()); 940 if ((nSearchType == -2) && (nAccessTypeID > 0)) //Match on any non-zero type 941 { 942 bFinished = true; 943 bFound = true; 944 dResult = (DateTime)dr["START_TIME"]; 945 break; 946 } 947 if (nAccessTypeID == nAVType) 948 { 949 bFinished = true; 950 bFound = true; 951 dResult = (DateTime)dr["START_TIME"]; 952 break; 953 } 954 } 955 } 956 dStart = dEnd.AddDays(1); 957 dEnd = dStart.AddDays(nIncrement); 958 if (dEnd > dtAVEnd) 959 dEnd = dtAVEnd; 960 } while (bFinished == false); 961 962 if (bFound == true) 963 { 964 aCopy.StartTime = dResult; 965 aCopy.EndTime = dResult.AddMinutes(a.Duration); 966 //Create the appointment 967 //Set the AUTOREBOOKED flag 968 //and store the "AutoRebooked To DateTime" 969 //in each autorebooked appointment 970 this.CreateAppointment(aCopy); 971 SetAutoRebook(a, dResult); 972 return "1"; 973 } 974 else 975 { 976 return "0"; 977 } 978 } 979 980 private void SetAutoRebook(CGAppointment a, DateTime dtRebookedTo) 981 { 982 string sApptKey = a.AppointmentKey.ToString(); 983 //string sRebookedTo = dtRebookedTo.ToString("M/d/yyyy@HH:mm"); 999 984 // i18n 1000 985 string sRebookedTo = FMDateTime.Create(dtRebookedTo).FMDateString; 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 string sNoShow = (bNoShow == true)?"1":"0";1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 986 string sSql = "BSDX REBOOK SET^" + sApptKey + "^" + sRebookedTo; 987 System.Data.DataTable dtRebook = m_DocManager.RPMSDataTable(sSql, "AutoRebook"); 988 989 } 990 991 public string AppointmentNoShow(int nApptID, bool bNoShow) 992 { 993 /* 994 * BSDX NOSHOW RPC Returns 1 in ERRORID if successfully sets NOSHOW flag in BSDX APPOINTMENT and, if applicable, File 2 995 *Otherwise, returns negative numbers for failure and errormessage in ERRORTXT 996 * 997 */ 998 999 string sTest = bNoShow.ToString(); 1000 string sNoShow = (bNoShow == true) ? "1" : "0"; 1001 string sSql = "BSDX NOSHOW^" + nApptID.ToString(); 1002 sSql += "^"; 1003 sSql += sNoShow; 1004 1005 DataTable dtAppt = m_DocManager.RPMSDataTable(sSql, "AppointmentNoShow"); 1006 1007 Debug.Assert(dtAppt.Rows.Count == 1); 1008 DataRow r = dtAppt.Rows[0]; 1009 string sErrorID = r["ERRORID"].ToString(); 1010 if (sErrorID != "1") 1011 { 1012 return r["ERRORTEXT"].ToString(); 1013 } 1014 1015 bool bRet = RefreshSchedule(); 1016 1017 return sErrorID; 1018 } 1019 1020 #endregion Methods 1021 1022 }//End class 1038 1023 }//End namespace -
Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs
r1070 r1071 181 181 _current = new CGDocumentManager(); 182 182 183 //Get command line options; store in private variables183 //Get command line options; store in private class wide variables 184 184 var opset = new OptionSet() { 185 185 { "s=", s => _current.m_Server = s }, … … 191 191 192 192 opset.Parse(args); 193 194 193 194 //Init app 195 195 bool isEverythingOkay = _current.InitializeApp(); 196 196 197 //if an error occurred, break out. 197 198 if (!isEverythingOkay) return; 198 199 199 200 //Create the first empty document 201 //A document holds the resources, appointments, and availabilites 200 202 //SAM: Good place for break point 201 203 CGDocument doc = new CGDocument(); 202 204 doc.DocManager = _current; 203 doc.OnNewDocument(); 205 206 //Create new View 207 //A view is a specific arrangement of appointments and availabilites that constitute a document 208 CGView view = new CGView(); 209 view.InitializeDocView(doc, _current, doc.StartDate, doc.Appointments, _current.WindowText); 210 211 //Handle BMX Event 204 212 Application.DoEvents(); 213 214 //Application wide error handler for unhandled errors 215 Application.ThreadException += new ThreadExceptionEventHandler(App_ThreadException); 216 205 217 #if TRACE 206 218 DateTime EndLoadTime = DateTime.Now; … … 208 220 Debug.Write("Load Time for GUI is " + LoadTime.Seconds + " s & " + LoadTime.Milliseconds + " ms\n"); 209 221 #endif 210 //Application wide error handler for unhandled errors 211 Application.ThreadException += new ThreadExceptionEventHandler(App_ThreadException); 212 213 //Run the application 214 //Sam's Note: This is an unusual way to call this. Typically, it's run with 215 //the main form as an argument. 222 223 view.Show(); 224 view.Activate(); 225 216 226 Application.Run(); 217 227 } … … 368 378 } 369 379 // My code -- buts looks so ugly! 380 // Checks the passed parameters stored in the class variables 370 381 else 371 382 { … … 981 992 } 982 993 994 /// <summary> 995 /// Accomplishes Changing the Server to which you connect 996 /// </summary> 997 /// <remarks> 998 /// Parameter relog-in for InitializeApp forces initialize app to use 999 /// 1. The server the user just picked and then BMX saved off to User Preferences 1000 /// 2. A new access and verify code pair 1001 /// </remarks> 1002 /// <param name="sender">unused</param> 1003 /// <param name="e">unused</param> 983 1004 private void mnuRPMSServer_Click(object sender, EventArgs e) 984 1005 { … … 990 1011 try 991 1012 { 1013 // Close All, but tell the Close All method not to call Applicaiton.Exit since we still plan to continue. 1014 // Close All does not call Application.Exit, but CGView_Close handler does 992 1015 m_bExitOK = false; 993 bool bRetry = true; 994 BMXNetConnectInfo tmpInfo; 1016 CloseAll(); 1017 m_bExitOK = true; 1018 1019 //Used in Do loop 1020 bool bRetry = true; 1021 1022 // Do Loop to deal with changing the server and the vagaries of user choices. 995 1023 do 996 1024 { 997 tmpInfo = m_ConnectInfo;998 1025 try 999 1026 { 1000 tmpInfo.ChangeServerInfo(); 1027 //ChangeServerInfo does not re-login the user 1028 //It only changes the saved server information in the %APPDATA% folder 1029 //so it can be re-used when BMX tries to log in again. 1030 //Access and Verify code are prompted for in InitializeApp 1031 m_ConnectInfo.ChangeServerInfo(); 1001 1032 bRetry = false; 1002 1033 } … … 1006 1037 { 1007 1038 bRetry = false; 1039 Application.Exit(); 1008 1040 return; 1009 1041 } … … 1015 1047 { 1016 1048 bRetry = false; 1049 Application.Exit(); 1017 1050 return; 1018 1051 } … … 1020 1053 } while (bRetry == true); 1021 1054 1022 CloseAll(); 1023 m_bExitOK = true; 1024 m_ConnectInfo = tmpInfo; 1025 1026 this.InitializeApp(); 1027 1028 //Create a new document 1029 CGDocument doc = new CGDocument(); 1030 doc.DocManager = _current; 1031 doc.OnNewDocument(); 1032 1055 //Parameter for initialize app tells it that this is a re-login and forces a new access and verify code. 1056 bool isEverythingOkay = this.InitializeApp(true); 1057 1058 //if an error occurred, break out. This time we need to call Application.Exit since it's already running. 1059 if (!isEverythingOkay) 1060 { 1061 Application.Exit(); 1062 return; 1063 } 1064 1065 //Otherwise, everything is okay. So open document and view, then show and activate view. 1066 CGDocument doc = new CGDocument(); 1067 doc.DocManager = _current; 1068 1069 CGView view = new CGView(); 1070 view.InitializeDocView(doc, _current, doc.StartDate, doc.Appointments, _current.WindowText); 1071 1072 view.Show(); 1073 view.Activate(); 1074 1075 //Application.Run need not be called b/c it is already running. 1033 1076 } 1034 1077 catch (Exception ex) … … 1039 1082 } 1040 1083 1084 /// <summary> 1085 /// Accomplishes Re-login into RPMS/VISTA. Now all logic is in this event handler. 1086 /// </summary> 1087 /// <param name="sender">not used</param> 1088 /// <param name="e">not used</param> 1041 1089 private void mnuRPMSLogin_Click(object sender, EventArgs e) 1042 1090 { … … 1048 1096 try 1049 1097 { 1098 // Close All, but tell the Close All method not to call Applicaiton.Exit since we still plan to continue. 1099 // Close All does not call Application.Exit, but CGView_Close handler does 1050 1100 m_bExitOK = false; 1051 1101 CloseAll(); 1052 1102 m_bExitOK = true; 1053 //_current.m_ConnectInfo = new BMXNet.BMXNetConnectInfo();//smh redundant 1054 this.InitializeApp(true); 1055 //Create a new document 1056 CGDocument doc = new CGDocument(); 1057 doc.DocManager = _current; 1058 doc.OnNewDocument(); 1103 1104 //Parameter for initialize app tells it that this is a re-login and forces a new access and verify code. 1105 bool isEverythingOkay = this.InitializeApp(true); 1106 1107 //if an error occurred, break out. This time we need to call Application.Exit since it's already running. 1108 if (!isEverythingOkay) 1109 { 1110 Application.Exit(); 1111 return; 1112 } 1113 1114 //Otherwise, everything is okay. So open document and view, then show and activate view. 1115 CGDocument doc = new CGDocument(); 1116 doc.DocManager = _current; 1117 1118 CGView view = new CGView(); 1119 view.InitializeDocView(doc, _current, doc.StartDate, doc.Appointments, _current.WindowText); 1120 1121 view.Show(); 1122 view.Activate(); 1123 1124 //Application.Run need not be called b/c it is already running. 1059 1125 } 1060 1126 catch (Exception ex) -
Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.cs
r1070 r1071 347 347 // 348 348 this.mnuRPMSServer.Index = 3; 349 this.mnuRPMSServer.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftS; 349 350 this.mnuRPMSServer.Text = "Change VistA &Server"; 350 351 this.mnuRPMSServer.Click += new System.EventHandler(this.mnuRPMSServer_Click); … … 353 354 // 354 355 this.mnuRPMSLogin.Index = 4; 356 this.mnuRPMSLogin.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftL; 355 357 this.mnuRPMSLogin.Text = "Change VistA &Login"; 356 358 this.mnuRPMSLogin.Click += new System.EventHandler(this.mnuRPMSLogin_Click); … … 359 361 // 360 362 this.mnuRPMSDivision.Index = 5; 363 this.mnuRPMSDivision.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftD; 361 364 this.mnuRPMSDivision.Text = "Change VistA &Division"; 362 365 this.mnuRPMSDivision.Click += new System.EventHandler(this.mnuRPMSDivision_Click); … … 1544 1547 //We are doing this--Again? 1545 1548 v =this.DocManager.GetViewByResource(sSelectedTreeResourceArray); 1546 v.dateTimePicker1.Value = dDate; 1549 1550 //Position the Grid 1551 //XXX: This must be a better way to do this. 1552 v.dateTimePicker1.Value = dDate; 1553 v.StartDate = doc.StartDate; 1547 1554 1548 1555 //Get preferred time scale from resource info … … 2376 2383 2377 2384 this.SetDesktopLocation(this.DesktopLocation.X + 10, this.DesktopLocation.Y + 10); 2385 2386 //Show the Form 2387 this.Activate(); 2378 2388 } 2379 2389 … … 3094 3104 // Change Date on Document 3095 3105 this.Document.SelectedDate = dDate; 3096 3106 3107 // Do we need to update? 3108 bool isRefreshNeeded = this.Document.IsRefreshNeeded(); 3109 3097 3110 //Splash when loading and change Cursor 3098 this.Cursor = Cursors.WaitCursor; 3099 LoadSplash(); 3100 3101 this.Cursor = Cursors.Default; 3102 this.Document.RefreshDocument(); 3103 3111 if (isRefreshNeeded) 3112 { 3113 this.Cursor = Cursors.WaitCursor; 3114 LoadSplash(); 3115 this.Document.RefreshDocument(); 3116 StopSplash(); 3117 this.Cursor = Cursors.Default; 3118 } 3119 3120 3104 3121 if (this.Document.Resources.Count == 1) 3105 3122 { … … 3123 3140 //XXX: Need to investigate 3124 3141 this.Document.UpdateAllViews(); 3125 3126 StopSplash();3127 this.Cursor = Cursors.Default;3128 3142 } 3129 3143 -
Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj.user
r1070 r1071 37 37 </RemoteDebugMachine> 38 38 <StartAction>Project</StartAction> 39 <StartArguments> 40 </StartArguments> 39 <StartArguments>/s=172.16.16.108 /p=9250 /a=abeer12 /v=abc,4321</StartArguments> 41 40 <StartPage> 42 41 </StartPage>
Note:
See TracChangeset
for help on using the changeset viewer.