/// <summary> /// Creates a test order. /// </summary> /// <param name="patientId">The patient id.</param> /// <param name="appointmentDateTime">The appointment date time.</param> /// <param name="testCodes">The codes of the tests to order.</param> /// <returns>The lab order id if successful, -1 if not</returns> public static int CreateTestOrder(int patientId, DateTime appointmentDateTime, List <int> testCodes) { MySqlTransaction transaction = TransactionHelpers.BeginTransaction(); int orderId = LabTestOrderDAL.OrderTest(patientId, appointmentDateTime); foreach (int code in testCodes) { if (!HasTestsDAL.AddTestToOrder(orderId, code)) { transaction.Rollback(); return(-1); } } TransactionHelpers.CommitTransaction(transaction); return(orderId); }
private void buttonSubmitOrder_Click(object sender, EventArgs e) { if (this.listViewTests.Items.Count > 0) { DialogResult okToProceed = MessageBox.Show("After submitting an order, you will NOT be able to edit it!", "Please confirm you would like to continue", MessageBoxButtons.YesNo); if (okToProceed == DialogResult.Yes) { if (LabTestOrderDAL.HasTestOrder(this.patientId, this.visitDateTime)) { MessageBox.Show("A test order has already been placed for this visit"); return; } List <int> testCodes = new List <int>(); foreach (ListViewItem item in this.listViewTests.Items) { int code = int.Parse(item.Tag.ToString()); testCodes.Add(code); } int orderId = LabTestHelpers.CreateTestOrder(this.patientId, this.visitDateTime, testCodes); if (orderId == -1) { MessageBox.Show("Creating test order failed"); } else { this.switchMode(true); LabTestOrder order = new LabTestOrder(orderId, this.patientId, this.visitDateTime); this.order = order; } } } else { MessageBox.Show("Please add at least one test to the order"); } }
/// <summary> /// Initializes a new instance of the <see cref="Labs"/> class. /// </summary> /// <param name="patientId">The patient's id.</param> /// <param name="visitDateTime">The visit date time.</param> /// <param name="disableEditing">if set to <c>true</c> [disable editing].</param> public Labs(int patientId, DateTime visitDateTime, bool disableEditing = false) { InitializeComponent(); this.patientId = patientId; this.visitDateTime = visitDateTime; this.dateTimePickerTest.CustomFormat = Constants.Constants.DATE_TIME_PICKER_FORMAT; this.switchMode(LabTestOrderDAL.HasTestOrder(patientId, visitDateTime)); if (this.orderSubmitted) { this.order = LabTestOrderDAL.GetTestOrder(patientId, visitDateTime); } if (disableEditing) { this.initializeAdminView(); } this.initializeTestsComboBox(); this.initializeTestsListView(); }