///<summary>Inserts one AppointmentType into the database. Provides option to use the existing priKey.</summary> public static long Insert(AppointmentType appointmentType,bool useExistingPK){ if(!useExistingPK && PrefC.RandomKeys) { appointmentType.AppointmentTypeNum=ReplicationServers.GetKey("appointmenttype","AppointmentTypeNum"); } string command="INSERT INTO appointmenttype ("; if(useExistingPK || PrefC.RandomKeys) { command+="AppointmentTypeNum,"; } command+="AppointmentTypeName,AppointmentTypeColor,ItemOrder,IsHidden) VALUES("; if(useExistingPK || PrefC.RandomKeys) { command+=POut.Long(appointmentType.AppointmentTypeNum)+","; } command+= "'"+POut.String(appointmentType.AppointmentTypeName)+"'," + POut.Int (appointmentType.AppointmentTypeColor.ToArgb())+"," + POut.Int (appointmentType.ItemOrder)+"," + POut.Bool (appointmentType.IsHidden)+")"; if(useExistingPK || PrefC.RandomKeys) { Db.NonQ(command); } else { appointmentType.AppointmentTypeNum=Db.NonQ(command,true); } return appointmentType.AppointmentTypeNum; }
private void Open_CreateNewSession(object sender, RoutedEventArgs e) { AppointmentType at = new AppointmentType(); at.AMPM_Start.SelectedIndex = 0; at.AMPM_End.SelectedIndex = 0; at.ApptType.SelectedIndex = 0; at.ShowDialog(); // Refresh the grid //Refresh_SessionGrid(); Refresh_SessionGrid(sender, e); }
///<summary>Converts a DataTable to a list of objects.</summary> public static List<AppointmentType> TableToList(DataTable table){ List<AppointmentType> retVal=new List<AppointmentType>(); AppointmentType appointmentType; for(int i=0;i<table.Rows.Count;i++) { appointmentType=new AppointmentType(); appointmentType.AppointmentTypeNum = PIn.Long (table.Rows[i]["AppointmentTypeNum"].ToString()); appointmentType.AppointmentTypeName = PIn.String(table.Rows[i]["AppointmentTypeName"].ToString()); appointmentType.AppointmentTypeColor= Color.FromArgb(PIn.Int(table.Rows[i]["AppointmentTypeColor"].ToString())); appointmentType.ItemOrder = PIn.Int (table.Rows[i]["ItemOrder"].ToString()); appointmentType.IsHidden = PIn.Bool (table.Rows[i]["IsHidden"].ToString()); retVal.Add(appointmentType); } return retVal; }
public void UpdateAppointmentType(AppointmentType appointmentType) { Guard.Against.Null(appointmentType, nameof(appointmentType)); if (AppointmentTypeId == appointmentType.Id) { return; } AppointmentTypeId = appointmentType.Id; TimeRange = TimeRange.NewEnd(TimeRange.Start.AddMinutes(appointmentType.Duration)); var appointmentUpdatedEvent = new AppointmentUpdatedEvent(this); Events.Add(appointmentUpdatedEvent); }
public void GetAppointmentTypes_WhenCalled_ReturnsAppointmentTypes() { //Arrange var appointmentTypes = new AppointmentType[] { new AppointmentType() }; _mockAppointmentTypeRepository.Setup(m => m.GetAll()) .Returns(appointmentTypes); //Act var result = _service.GetAppointmentTypes(); //Assert result.Should().NotBeNull(); result.Should().BeEquivalentTo(appointmentTypes); }
///<summary>Inserts one AppointmentType into the database. Returns the new priKey. Doesn't use the cache.</summary> public static long InsertNoCache(AppointmentType appointmentType) { if (DataConnection.DBtype == DatabaseType.MySql) { return(InsertNoCache(appointmentType, false)); } else { if (DataConnection.DBtype == DatabaseType.Oracle) { appointmentType.AppointmentTypeNum = DbHelper.GetNextOracleKey("appointmenttype", "AppointmentTypeNum"); //Cacheless method } return(InsertNoCache(appointmentType, true)); } }
public void CheckType(Appointment appointment) { AppointmentType appointmentType = appointment.AppointmentType; Doctor doctor = appointment.DoctorInAppointment; Patient patient = appointment.Patient; if (appointmentType == AppointmentType.operation && (doctor.DoctorType == DoctorType.FAMILYMEDICINE)) { throw new AppointmentServiceException("Family medicine doctor can not book operation!"); } else if (appointmentType == AppointmentType.renovation && (doctor != null || patient != null)) { throw new AppointmentServiceException("Doctor and patient can not be in renovation appointment!"); } }
public Appointment ConvertCSVToEntity(string csv) { string[] tokens = SplitStringByDelimiter(csv, _delimiter); AppointmentType appointmentType = (AppointmentType)Enum.Parse(typeof(AppointmentType), tokens[4]); //Casting string to Enum. return(new Appointment( long.Parse(tokens[0]), GetDummyDoctor(tokens[1]), GetDummyPatient(tokens[2]), GetDummyRoom(tokens[3]), appointmentType, GetTimeInterval(SplitStringByDelimiter(tokens[5], _listDelimiter)), bool.Parse(tokens[6]) )); }
public void GetAvailableTimesTest() { Client testClient = new Client(); DateTime testDateTime = new DateTime(2019, 06, 17, 9, 0, 0); AppointmentType testAppointmentType = new AppointmentType("TestAppointment", 70, TimeSpan.FromHours(2)); Room testRoom = new Room("B"); List <User> users = new List <User> { testClient, _testPractitioner }; Appointment appointmentOne = new Appointment(testDateTime, users, testAppointmentType, testRoom, "", TimeSpan.FromHours(5), false, false); List <DateTime> availableTimes = _testPractitioner.GetAvailableTimes(testDateTime.Date); Assert.IsFalse(availableTimes.Contains(testDateTime.AddHours(1))); }
public async Task AddAppointmentShouldAddAppointmentWithAllTypes( AppointmentType type) { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()).Options; var db = new ApplicationDbContext(options); var appointmentsRepository = new EfDeletableEntityRepository <Appointment>(db); var usersRepository = new EfDeletableEntityRepository <ApplicationUser>(db); var notificationsService = new Mock <INotificationsService>(); var service = new AppointmentsService( appointmentsRepository, usersRepository, notificationsService.Object); var client = new ApplicationUser(); var trainer = new ApplicationUser(); var role = new ApplicationRole(GlobalConstants.TrainerRoleName); var identityRole = new IdentityUserRole <string>() { RoleId = role.Id, UserId = trainer.Id, }; trainer.Roles.Add(identityRole); await usersRepository.AddAsync(trainer); await usersRepository.AddAsync(client); await usersRepository.SaveChangesAsync(); var inputModel = new AddAppointmentInputModel() { StartTime = DateTime.UtcNow, EndTime = DateTime.UtcNow.AddDays(2), ClientId = client.Id, TrainerId = trainer.Id, IsApproved = true, Notes = null, Type = type, }; var result = await service.AddAppoinmentAsync(inputModel); Assert.Equal(type, result.Type); }
public void TestCreateAppointmentTypeDescriptionTooLong() { // arrange AppointmentType testAppointmentType = new AppointmentType() { AppointmentTypeID = "GoodID", Description = createLongString(1001), }; string badDescription = testAppointmentType.Description; // act bool result = appointmenttManager.AddAppointmentType(testAppointmentType); // assert - check that description did not change Assert.AreEqual(badDescription, testAppointmentType.Description); }
/// <summary> /// Wes Richardson /// Created: 2019/03/07 /// /// Gets a list of appointment types and their descriptions /// </summary> public List <AppointmentType> SelectAppointmentTypes() { List <AppointmentType> appointmentTypes = null; var conn = DBConnection.GetDbConnection(); var cmdText = @"sp_select_appointment_types"; var cmd = new SqlCommand(cmdText, conn); cmd.CommandType = System.Data.CommandType.StoredProcedure; try { conn.Open(); var reader = cmd.ExecuteReader(); if (reader.HasRows) { appointmentTypes = new List <AppointmentType>(); while (reader.Read()) { var apt = new AppointmentType() { AppointmentTypeID = reader.GetString(0), Description = reader.GetString(1) }; appointmentTypes.Add(apt); } } else { throw new ApplicationException("Appointment Type data not found"); } } catch (Exception ex) { throw new ApplicationException("Database access error", ex); } finally { conn.Close(); } return(appointmentTypes); }
public static AppointmentType CreateAppointmentType(string appointmentTypeName, Color appointmentTypeColor = new Color(), string codeStr = "" , bool isHidden = false, int itemOrder = 0, string pattern = "") { AppointmentType appointmentType = new AppointmentType() { AppointmentTypeName = appointmentTypeName, AppointmentTypeColor = appointmentTypeColor, CodeStr = codeStr, IsHidden = isHidden, ItemOrder = itemOrder, Pattern = pattern, }; AppointmentTypes.Insert(appointmentType); AppointmentTypes.RefreshCache(); return(appointmentType); }
public void TestCreateAppointmentTypeAppointmentTypeIDTooLong() { // arrange AppointmentType testAppointmentType = new AppointmentType() { AppointmentTypeID = createLongString(51), Description = "Good Description", }; string badAppointmentTypeID = testAppointmentType.AppointmentTypeID; // act bool result = appointmenttManager.AddAppointmentType(testAppointmentType); // assert - check that AppointmentTypeID did not change Assert.AreEqual(badAppointmentTypeID, testAppointmentType.AppointmentTypeID); }
public FormDefEditWSNPApptTypes(Def defCur) { InitializeComponent(); Lan.F(this); _defCur = defCur; checkHidden.Checked = _defCur.IsHidden; textName.Text = _defCur.ItemName; //Look for an associated appointment type. List <DefLink> listDefLinks = DefLinks.GetDefLinksByType(DefLinkType.AppointmentType); DefLink defLink = listDefLinks.FirstOrDefault(x => x.DefNum == _defCur.DefNum); if (defLink != null) { _apptTypeCur = AppointmentTypes.GetFirstOrDefault(x => x.AppointmentTypeNum == defLink.FKey); } FillTextValue(); }
public void ThenTheAddResultShouldBeAAppointmentTypeIdCheckExistsGetByIdEditAndDeleteWithHttpResponseReturns() { //did we get a good result Assert.IsTrue(_addItem != null && _addItem.Id > 0); //set the returned AddID to current Get _addedIdValue = _addItem.Id; _getIdValue = _addedIdValue; _existsIdValue = _getIdValue; //check that the item exists var itemReturned = Exists(_existsIdValue); Assert.IsTrue(itemReturned); //use the value used in exists check _getIdValue = _addItem.Id; Assert.IsTrue(_getIdValue == _addedIdValue); //pull the item by Id var resultGet = GetById <AppointmentType>(_getIdValue); Assert.IsNotNull(resultGet); _getIdValue = resultGet.Id; Assert.IsTrue(_getIdValue == _addedIdValue); //Now, let's Edit the newly added item _editIdValue = _getIdValue; _editItem = resultGet; Assert.IsTrue(_editIdValue == _addedIdValue); //do an update var updateResponse = Update(_editIdValue, _editItem); Assert.IsNotNull(updateResponse); //pass the item just updated _deletedIdValue = _editIdValue; Assert.IsTrue(_deletedIdValue == _addedIdValue); //delete this same item var deleteResponse = Delete(_deletedIdValue); Assert.IsNotNull(deleteResponse); }
/// <summary> /// Gets all the practitioners from database and returns them as a list of practitioner objects. /// </summary> /// <returns></returns> public List <Practitioner> GetPractitioners() { List <Practitioner> listOfPractitioners = new List <Practitioner>(); using (SqlConnection connection = new SqlConnection(_connectionString)) { connection.Open(); SqlCommand command = new SqlCommand("SPGetAllPractitioners", connection); command.CommandType = CommandType.StoredProcedure; SqlCommand appointmentCommand = new SqlCommand("SPGetAppointmentTypeByPractitionerId", connection); appointmentCommand.CommandType = CommandType.StoredProcedure; using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { List <AppointmentType> appointmentTypes = new List <AppointmentType>(); appointmentCommand.Parameters.AddWithValue("PractitionerId", reader.GetInt32(0)); using (SqlDataReader appointmentReader = appointmentCommand.ExecuteReader()) { while (appointmentReader.Read()) { AppointmentType tempAppointmentType = new AppointmentType(appointmentReader.GetString(0), appointmentReader.GetDouble(1), appointmentReader.GetTimeSpan(2), appointmentReader.GetInt32(3)); appointmentTypes.Add(tempAppointmentType); } } Practitioner tempPractitioner = new Practitioner(reader.GetInt32(0), appointmentTypes, reader.GetDateTime(5), reader.GetTimeSpan(6), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4)); listOfPractitioners.Add(tempPractitioner); appointmentCommand.Parameters.Clear(); } } } return(listOfPractitioners); }
public void GetAvailabilityTest() { Client testClient = new Client(); DateTime testDateTime = new DateTime(2019, 05, 12, 10, 0, 0); AppointmentType testAppointmentType = new AppointmentType("Test", 1200, TimeSpan.FromHours(1)); Room testRoom = new Room("A"); List <User> users = new List <User> { testClient, _testPractitioner }; Appointment appointmentOne = new Appointment(testDateTime, users, testAppointmentType, testRoom, "", TimeSpan.FromHours(5), false, false); DateTime tomorrow = DateTime.Today.AddDays(1); DateTime inOneYear = tomorrow.AddYears(1); List <DateTime> availableTimeSpans = _testPractitioner.GetAvailability(tomorrow, inOneYear); Assert.IsFalse(availableTimeSpans.Contains(testDateTime)); }
public void TestCreateAppointmentTypeValidInputMaxLengths() { bool expectedResult = true; bool actualResult; // arrange AppointmentType testAppointmentType = new AppointmentType() { AppointmentTypeID = createLongString(50), Description = createLongString(1000), }; // act actualResult = appointmenttManager.AddAppointmentType(testAppointmentType); // assert - check if AppointmentType was added Assert.AreEqual(expectedResult, actualResult); }
public void TestCreateAppointmentTypeValidInput() { bool expectedResult = true; bool actualResult; // arrange AppointmentType testAppointmentType = new AppointmentType() { AppointmentTypeID = "GoodID", Description = "Good Long Description", }; // act actualResult = appointmenttManager.AddAppointmentType(testAppointmentType); // assert - check if AppointmentType was added Assert.AreEqual(expectedResult, actualResult); }
public void CreateAndAddAppointment(DateTime dateAndTime, Room room, List <User> users, AppointmentType appointmentType, string note, TimeSpan notificationTime, bool emailNotification, bool smsNotification) { lock (_lockingObject) { Appointment tempAppointment = CreateAppointment(dateAndTime, users, appointmentType, room, note, notificationTime, emailNotification, smsNotification); AddAppointment(tempAppointment); _updateAppointmentNotification.AppointmentCreatedNotification(tempAppointment); _persistable.SaveAppointment(dateAndTime, room, users, appointmentType, note, notificationTime, emailNotification, smsNotification); AppointmentsChangedEventHandler?.Invoke(tempAppointment, EventArgs.Empty); } }
public IActionResult Create(AppointmentType appointmentType) { if (!ModelState.IsValid) { var errors = ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage).ToList(); return(BadRequest(errors)); } var name = appointmentType.Name.Trim().ToLower(); if (_appointmentTypeRepository.GetByName(name) == true) { return(BadRequest("This appointment type already exists.")); } _appointmentTypeRepository.Create(appointmentType); return(Ok()); }
void ExportAppointment(Appointment apt) { AppointmentType aptType = apt.Type; if (aptType == AppointmentType.Pattern) { EnsurePatternId(apt); } else if (aptType != AppointmentType.Normal) { string eventPatternId = EnsurePatternId(apt.RecurrencePattern); Debug.Assert(!String.IsNullOrEmpty(eventPatternId)); if (aptType == AppointmentType.Occurrence) { return; } EventsResource.InstancesRequest instancesRequest = CalendarService.Events.Instances(CalendarEntry.Id, eventPatternId); OccurrenceCalculator calculator = OccurrenceCalculator.CreateInstance(apt.RecurrencePattern.RecurrenceInfo); instancesRequest.OriginalStart = GoogleCalendarUtils.ConvertEventDateTime(calculator.CalcOccurrenceStartTime(apt.RecurrenceIndex)).DateTimeRaw; Events occurrenceEvents = instancesRequest.Execute(); Debug.Assert(occurrenceEvents.Items.Count == 1); Event occurrence = occurrenceEvents.Items[0]; if (aptType == AppointmentType.ChangedOccurrence) { this.AssignProperties(apt, occurrence); } else if (aptType == AppointmentType.DeletedOccurrence) { occurrence.Status = "cancelled"; } Event changedOccurrence = CalendarService.Events.Update(occurrence, CalendarEntry.Id, occurrence.Id).Execute(); apt.CustomFields["eventId"] = changedOccurrence.Id; Log.WriteLine(String.Format("Exported {0} occurrance: {1}, id={2}", (aptType == AppointmentType.ChangedOccurrence) ? "changed" : "deleted", apt.Subject, changedOccurrence.Id)); return; } Event instance = this.CreateEvent(aptType); AssignProperties(apt, instance); Event result = CalendarService.Events.Insert(instance, CalendarEntry.Id).Execute(); Log.WriteLine(String.Format("Exported appointment: {0}, id={1}", apt.Subject, result.Id)); }
public static bool IsValid(AppointmentType appointmentType) { var isValid = true; if (appointmentType == null) { return(false); } else if (appointmentType.Id <= 0) { return(false); } else if (string.IsNullOrEmpty(appointmentType.Name)) { return(false); } return(isValid); }
/// <summary author="Craig Barkley" created="2019/02/05"> /// Method that Adds an Appointment Type /// </summary> /// <param name="appointmentType">The newAppointmentType is passed to the CreateAppointmentType</param> /// <returns> Results </returns> public bool AddAppointmentType(AppointmentType newAppointmentType) { ValidationExtensionMethods.ValidateID(newAppointmentType.AppointmentTypeID); ValidationExtensionMethods.ValidateDescription(newAppointmentType.Description); bool result = false; try { result = (1 == _appointmentTypeAccessor.CreateAppointmentType(newAppointmentType)); } catch (Exception ex) { ExceptionLogManager.getInstance().LogException(ex); throw ex; } return(result); }
private void butDelete_Click(object sender, EventArgs e) { if (AppointmentTypeCur.IsNew) { DialogResult = DialogResult.Cancel; return; } else { string msg = AppointmentTypes.CheckInUse(AppointmentTypeCur.AppointmentTypeNum); if (!string.IsNullOrWhiteSpace(msg)) { MsgBox.Show(this, msg); return; } AppointmentTypeCur = null; DialogResult = DialogResult.OK; } }
public void GetAppointmentTypeById_ValidDataResponse_Test() { //Arrage IDbContext dbContext = new MedicalAppointmentContext(); IRepository repository = new AppointmentTypeRepository(dbContext); var sut = new AppointmentTypesController(repository); var expectedResult = new AppointmentType() { Id = 1, Name = "Medicina General" }; //Act var result = sut.Get(1) as OkNegotiatedContentResult <IAppointmentType>; var appointmentTypeResult = result.Content as AppointmentType; //Assert Assert.AreEqual(expectedResult.Id, appointmentTypeResult.Id); Assert.AreEqual(expectedResult.Name, appointmentTypeResult.Name); }
private static void SetViewBagForConfirmationLetter(this Controller cntlr, ConsularApptVM consularApptVM) { if (cntlr.ViewBag.Logo == null) { string basePath = AppDomain.CurrentDomain.BaseDirectory; cntlr.ViewBag.Logo = Graphics.GetImgSrcForPdf(basePath + DpWebAppConfig.Emblem_Logo); } // Get Service Type look up if (cntlr.ViewBag.AppointmentType == null) { AppointmentType appointmentType = ConsularAppointmentTypes.GetAppointmentType(consularApptVM.AppointmentType); cntlr.ViewBag.AppointmentType = appointmentType.Description; } // Get QR code if (cntlr.ViewBag.QR == null) { cntlr.ViewBag.QR = Graphics.GenerateRelayQrCode(ConfirmationLetterPdf.GetQrCodeString(consularApptVM)); } }
private void Confirm_Click(object sender, RoutedEventArgs e) { Patient patient = (Patient)PatientComboBox.SelectedItem; Doctor doctor = (Doctor)DoctorComboBox.SelectedItem; Room room = (Room)RoomComboBox.SelectedItem; if (ConfirmCheck()) { ComboBoxItem item = time.SelectedItem as ComboBoxItem; DateTime dateTime = DateTime.Parse(date.Text + " " + item.Content.ToString()); AppointmentType type = (AppointmentType)TypeComboBox.SelectedIndex; Appointment appointment = new Appointment(_appointmentController.GenerateNewId(), dateTime, 15, type, AppointmentStatus.scheduled, patient, doctor, room); _appointmentController.Add(appointment); parent.Main.Content = new AppointmentsPage(parent); this.Close(); } }
///<summary>Converts a DataTable to a list of objects.</summary> public static List <AppointmentType> TableToList(DataTable table) { List <AppointmentType> retVal = new List <AppointmentType>(); AppointmentType appointmentType; foreach (DataRow row in table.Rows) { appointmentType = new AppointmentType(); appointmentType.AppointmentTypeNum = PIn.Long(row["AppointmentTypeNum"].ToString()); appointmentType.AppointmentTypeName = PIn.String(row["AppointmentTypeName"].ToString()); appointmentType.AppointmentTypeColor = Color.FromArgb(PIn.Int(row["AppointmentTypeColor"].ToString())); appointmentType.ItemOrder = PIn.Int(row["ItemOrder"].ToString()); appointmentType.IsHidden = PIn.Bool(row["IsHidden"].ToString()); appointmentType.Pattern = PIn.String(row["Pattern"].ToString()); appointmentType.CodeStr = PIn.String(row["CodeStr"].ToString()); retVal.Add(appointmentType); } return(retVal); }
internal IList <AppointmentType> toAppointmentTypes(string response) { if (String.IsNullOrEmpty(response)) { return(new List <AppointmentType>()); } IList <AppointmentType> appts = new List <AppointmentType>(); string[] lines = StringUtils.split(response, StringUtils.CRLF); if (lines == null || lines.Length == 0) { throw new MdoException(MdoExceptionCode.DATA_UNEXPECTED_FORMAT); } string[] metaLine = StringUtils.split(lines[0], StringUtils.EQUALS); string[] metaPieces = StringUtils.split(metaLine[1], StringUtils.CARET); Int32 numResult = Convert.ToInt32(metaPieces[0]); // metaPieces[1] = number of records requested (number argument). asterisk means all were returned // metaPieces[2] = ? for (int i = 1; i < lines.Length; i++) { string[] pieces = StringUtils.split(lines[i], StringUtils.EQUALS); if (pieces.Length < 2 || String.IsNullOrEmpty(pieces[1])) // at the declaration of a new result - create a new appointment type { if (lines.Length >= i + 2) // just to be safe - check there are two more lines so we can obtain the ID and name { AppointmentType current = new AppointmentType(); current.ID = (StringUtils.split(lines[i + 1], StringUtils.EQUALS))[1]; current.Name = (StringUtils.split(lines[i + 2], StringUtils.EQUALS))[1]; appts.Add(current); } } } // TBD - should we check the meta info matched the number of results found? return(appts); }
public async Task <BookingRequest> MapBookingRequest(string sessionGuid, IElement bookingElement, Dictionary <string, dynamic> viewModel, string form) { var(convertedAnswers, baseForm) = await GetFormAnswers(form, sessionGuid); AppointmentType appointmentType = bookingElement.Properties.AppointmentTypes .GetAppointmentTypeForEnvironment(_environment.EnvironmentName); if (appointmentType.NeedsAppointmentIdMapping) { MapAppointmentId(appointmentType, convertedAnswers); } return(new BookingRequest { AppointmentId = appointmentType.AppointmentId, Customer = await GetCustomerBookingDetails(convertedAnswers, baseForm, bookingElement), StartDateTime = GetStartDateTime(bookingElement.Properties.QuestionId, viewModel, form), OptionalResources = appointmentType.OptionalResources }); }
public void CheckType(Appointment appointment) { AppointmentType appointmentType = appointment.AppointmentType; Doctor doctor = appointment.DoctorInAppointment; Patient patient = appointment.Patient; Room room = appointment.Room; if (appointmentType == AppointmentType.operation && (doctor.DoctorType == DoctorType.FAMILYMEDICINE)) { throw new AppointmentServiceException("Family medicine doctor can not book operation!"); } if (appointmentType == AppointmentType.renovation) { throw new AppointmentServiceException("Secretary cannot book renovation!"); } if (doctor == null || patient == null || room == null) { throw new AppointmentServiceException("Doctor, patient and room must be set."); } }
public Appointment(Dictionary<String, String> appointment) { string temp; type = AppointmentType.OverView; if (appointment.TryGetValue("trm_datum", out temp)) { trm_Datum = DateTime.Parse(temp); } if (appointment.TryGetValue("trm_zeitanfang", out temp)) { trm_zeitanfang = DateTime.Parse(temp); } if (appointment.TryGetValue("trm_zeitende", out temp)) { trm_zeitende = DateTime.Parse(temp); type = AppointmentType.Details; } if (appointment.TryGetValue("trm_zeitecht", out temp)) { trm_zeitecht = DateTime.Parse(temp); type = AppointmentType.Details; } if (appointment.TryGetValue("trm_modificationtime", out temp)) { trm_modificationtime = DateTime.Parse(temp); type = AppointmentType.Details;} if (appointment.TryGetValue("trm_link", out temp)) { trm_link = temp;} if (appointment.TryGetValue("trm_ort", out temp)) { trm_ort = temp;} if (appointment.TryGetValue("trm_bezeichnung", out temp)) { trm_bezeichnung = temp;} if (appointment.TryGetValue("trm_beschreibung", out temp)) { trm_beschreibung = temp;} if (appointment.TryGetValue("trm_detailsintern", out temp)) { trm_detailsintern = temp;} if (appointment.TryGetValue("trm_anzeige", out temp)) { trm_anzeige = temp;} if (appointment.TryGetValue("trm_typ", out temp)) { trm_typ = temp;} if (appointment.TryGetValue("trm_style", out temp)) { trm_style = temp;} if (appointment.TryGetValue("trm_abmeldungtage", out temp)) { trm_abmeldungtage = Int32.Parse(temp);} if (appointment.TryGetValue("trm_instatistik", out temp)) { trm_instatistik = Int32.Parse(temp);} if (appointment.TryGetValue("trm_id", out temp)) { trm_id = temp; } if (appointment.TryGetValue("abm_status", out temp)) { trm_angemeldet = temp.Equals("angemeldet"); } }
///<summary>Inserts one AppointmentType into the database. Returns the new priKey.</summary> public static long Insert(AppointmentType appointmentType){ if(DataConnection.DBtype==DatabaseType.Oracle) { appointmentType.AppointmentTypeNum=DbHelper.GetNextOracleKey("appointmenttype","AppointmentTypeNum"); int loopcount=0; while(loopcount<100){ try { return Insert(appointmentType,true); } catch(Oracle.DataAccess.Client.OracleException ex){ if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){ appointmentType.AppointmentTypeNum++; loopcount++; } else{ throw ex; } } } throw new ApplicationException("Insert failed. Could not generate primary key."); } else { return Insert(appointmentType,false); } }
/// <summary> /// RESULT(\"DEFAULT ELIGIBILITY\")=4^COLLATERAL OF VET. //RESULT(\"DESCRIPTION\")=REC(409.1,\"7,\",\"DESCRIPTION\")^REC(409.1,\"7,\",\"DESCRIPTION\") //RESULT(\"DUAL ELIGIBILITY ALLOWED\")=1^YES //RESULT(\"IGNORE MEANS TEST BILLING\")=1^IGNORE //RESULT(\"INACTIVE\")= //RESULT(\"NAME\")=COLLATERAL OF VET.^COLLATERAL OF VET. //RESULT(\"NUMBER\")=7^7 //RESULT(\"SYNONYM\")=COV^COV /// </summary> /// <param name="response"></param> /// <returns></returns> internal AppointmentType toAppointmentTypeDetails(string response) { AppointmentType result = new AppointmentType(); if (String.IsNullOrEmpty(response)) { return result; } string[] lines = StringUtils.split(response, StringUtils.CRLF); if (lines == null || lines.Length == 0) { return result; } foreach (string line in lines) { string[] pieces = StringUtils.split(line, StringUtils.EQUALS); if (pieces == null || pieces.Length != 2) { continue; } string fieldLabel = StringUtils.extractQuotedString(pieces[0]); string[] dataPieces = StringUtils.split(pieces[1], StringUtils.CARET); if (dataPieces == null || dataPieces.Length != 2) { continue; } switch (fieldLabel) { case "DEFAULT ELGIBILITY": break; case "DESCRIPTION": result.Description = dataPieces[1]; break; case "DUAL ELIGIBILITY ALLOWED": break; case "IGNORE MEANS TEST BILLING": break; case "INACTIVE": // haven't seen this populated anywhere - what value comes across for inactive?? //result.Active = (dataPieces[1] == "I"); // this was just a guess - probably "1" or "0" break; case "NAME": result.Name = dataPieces[1]; break; case "NUMBER": result.ID = dataPieces[1]; break; case "SYNONYM": result.Synonym = dataPieces[1]; break; } } return result; }
///<summary>Updates one AppointmentType in the database.</summary> public static void Update(AppointmentType appointmentType){ string command="UPDATE appointmenttype SET " +"AppointmentTypeName = '"+POut.String(appointmentType.AppointmentTypeName)+"', " +"AppointmentTypeColor= "+POut.Int (appointmentType.AppointmentTypeColor.ToArgb())+", " +"ItemOrder = "+POut.Int (appointmentType.ItemOrder)+", " +"IsHidden = "+POut.Bool (appointmentType.IsHidden)+" " +"WHERE AppointmentTypeNum = "+POut.Long(appointmentType.AppointmentTypeNum); Db.NonQ(command); }
///<summary>Updates one AppointmentType in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(AppointmentType appointmentType,AppointmentType oldAppointmentType){ string command=""; if(appointmentType.AppointmentTypeName != oldAppointmentType.AppointmentTypeName) { if(command!=""){ command+=",";} command+="AppointmentTypeName = '"+POut.String(appointmentType.AppointmentTypeName)+"'"; } if(appointmentType.AppointmentTypeColor != oldAppointmentType.AppointmentTypeColor) { if(command!=""){ command+=",";} command+="AppointmentTypeColor = "+POut.Int(appointmentType.AppointmentTypeColor.ToArgb())+""; } if(appointmentType.ItemOrder != oldAppointmentType.ItemOrder) { if(command!=""){ command+=",";} command+="ItemOrder = "+POut.Int(appointmentType.ItemOrder)+""; } if(appointmentType.IsHidden != oldAppointmentType.IsHidden) { if(command!=""){ command+=",";} command+="IsHidden = "+POut.Bool(appointmentType.IsHidden)+""; } if(command==""){ return false; } command="UPDATE appointmenttype SET "+command +" WHERE AppointmentTypeNum = "+POut.Long(appointmentType.AppointmentTypeNum); Db.NonQ(command); return true; }
internal IList<AppointmentType> toAppointmentTypes(string response) { if (String.IsNullOrEmpty(response)) { return new List<AppointmentType>(); } IList<AppointmentType> appts = new List<AppointmentType>(); string[] lines = StringUtils.split(response, StringUtils.CRLF); if (lines == null || lines.Length == 0) { throw new MdoException(MdoExceptionCode.DATA_UNEXPECTED_FORMAT); } string[] metaLine = StringUtils.split(lines[0], StringUtils.EQUALS); string[] metaPieces = StringUtils.split(metaLine[1], StringUtils.CARET); Int32 numResult = Convert.ToInt32(metaPieces[0]); // metaPieces[1] = number of records requested (number argument). asterisk means all were returned // metaPieces[2] = ? for (int i = 1; i < lines.Length; i++) { string[] pieces = StringUtils.split(lines[i], StringUtils.EQUALS); if (pieces.Length < 2 || String.IsNullOrEmpty(pieces[1])) // at the declaration of a new result - create a new appointment type { if (lines.Length >= i + 2) // just to be safe - check there are two more lines so we can obtain the ID and name { AppointmentType current = new AppointmentType(); current.ID = (StringUtils.split(lines[i + 1], StringUtils.EQUALS))[1]; current.Name = (StringUtils.split(lines[i + 2], StringUtils.EQUALS))[1]; appts.Add(current); } } } // TBD - should we check the meta info matched the number of results found? return appts; }