private void createPatient(RADGSHALibrary.Patient patient) { RADGSHALibrary.DBConnectionObject conn = RADGSHALibrary.DBConnectionObject.getInstance(); List <RADGSHALibrary.Patient> checkForSSN = conn.queryPatient(patient.getSSN(), "", "", ""); if (checkForSSN.Count > 0) { string message = "Error! A patient with that SSN already exists! Is this patient already in the database?"; string caption = "Error!"; MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show(message, caption, buttons); } else { conn.addPatient(patient); this.Hide(); clearForm(); Patient p = new Patient(this, patient); p.Closed += (s, args) => this.Close(); p.Show(); } }
public CheckOut(Form newPreviousForm, ref RADGSHALibrary.Patient newSelectedPatient, ref RADGSHALibrary.Visit newSelectedVisit) { RADGSHALibrary.DBConnectionObject conn = RADGSHALibrary.DBConnectionObject.getInstance(); InitializeComponent(); previousForm = newPreviousForm; selectedPatient = newSelectedPatient; selectedVisit = newSelectedVisit; roomSubtotal = inventorySubtotal = serviceSubtotal = 0; exit = DateTime.Now; // keep track of when we bring up this form patientName.Text = selectedPatient.getLastName() + ", " + selectedPatient.getFirstName(); foreach (RADGSHALibrary.Room r in selectedVisit.getRoomList()) { // Room number ListViewItem roomNumber = new ListViewItem(r.getRoomNumber()); // Rate roomNumber.SubItems.Add(r.getHourlyRate().ToString()); // Length of stay DateTime entry; DateTime roomExit; bool stillInRoom; conn.getRoomEntryExitDates(selectedPatient, selectedVisit, r, out entry, out roomExit, out stillInRoom); if (stillInRoom) { roomExit = DateTime.Now; } TimeSpan length = (roomExit - entry); string lengthOfStay = ""; if (length.Days > 0) { lengthOfStay += length.Days.ToString() + " Days, "; } if (length.Hours > 0) { lengthOfStay += length.Hours.ToString() + " Hours, "; } lengthOfStay += length.Minutes.ToString() + " Minutes"; roomNumber.SubItems.Add(lengthOfStay); // Charge //decimal lengthAdjusted = (decimal)length.TotalDays * 24; //Console.WriteLine(lengthAdjusted); decimal lengthAdjusted = (decimal)length.TotalHours; Console.WriteLine(lengthAdjusted); // lengthAdjusted += (decimal)length.TotalMinutes / 60; Console.WriteLine(lengthAdjusted); decimal amnt = lengthAdjusted * r.getHourlyRate(); amnt = Decimal.Round(amnt, 2); roomNumber.SubItems.Add(amnt.ToString()); roomListView.Items.Add(roomNumber); roomSubtotal += amnt; } List <string> inventoryUsed = conn.queryUses(selectedPatient, selectedVisit); List <int> quantityUsed = new List <int>(); foreach (string s in inventoryUsed) { int quantity = conn.getUses(selectedPatient, selectedVisit, s); quantityUsed.Add(quantity); RADGSHALibrary.Inventory i = conn.getInventory(s); if (conn.isItem(i)) // add to items { decimal curCost = 0; ListViewItem items = new ListViewItem(i.getDescription()); items.SubItems.Add(quantity.ToString()); curCost = i.getCost(); curCost = Decimal.Round(curCost, 2); items.SubItems.Add(curCost.ToString()); decimal itemTotal = curCost * quantity; itemTotal = Decimal.Round(itemTotal, 2); items.SubItems.Add(itemTotal.ToString()); inventorySubtotal += itemTotal; suppliesListView.Items.Add(items); } else // add to services { decimal curCost = 0; ListViewItem items = new ListViewItem(i.getDescription()); // items.SubItems.Add(quantity.ToString()); curCost = i.getCost(); curCost = Decimal.Round(curCost, 2); items.SubItems.Add(curCost.ToString()); // decimal itemTotal = curCost * quantity; // items.SubItems.Add(itemTotal.ToString()); serviceSubtotal += curCost; proceduresListView.Items.Add(items); } } roomSubtotal = Decimal.Round(roomSubtotal, 2); serviceSubtotal = Decimal.Round(serviceSubtotal, 2); inventorySubtotal = Decimal.Round(inventorySubtotal, 2); textRoomSub.Text = roomSubtotal.ToString(); textServicesSub.Text = serviceSubtotal.ToString(); textSuppliesSub.Text = inventorySubtotal.ToString(); total = roomSubtotal + serviceSubtotal + inventorySubtotal; totalDue.Text = total.ToString(); }
private void saveButton_Click(object sender, EventArgs e) { RADGSHALibrary.Patient patient; // Sanitize SSN string patientSSNSanitized = patientSSN.Text.Trim(); patientSSNSanitized = patientSSNSanitized.Replace("-", ""); string errorMessage = ""; bool success = int.TryParse(patientSSNSanitized, out int notUsing); if (!success) { errorMessage = "Error: SSN is not in proper format!"; } if (patientSSNSanitized.Length != 9) { success = false; errorMessage = "Error: SSN is not proper length!"; } if (success) { try { patient = new RADGSHALibrary.Patient(patientSSNSanitized); patient.setAddressLine1(patientAddressLine1TextBox.Text.Trim()); patient.setAddressLine2(patientAddressLine2TextBox.Text.Trim()); // check insurer format if (patientInsurer.Text.Trim().Length > 0) // patient might not have an insurer { bool tryInsurer = int.TryParse(patientInsurer.Text.Trim(), out notUsing); if (!tryInsurer) { success = false; errorMessage = "Error: Insurer ID must be numerical!"; } patient.setInsurer(patientInsurer.Text.Trim()); } patient.setBirthDate(birthDate.Value); patient.setCity(patientCityTextBox.Text.Trim()); // check zipcode value and format string zipcodeSanitized = patientZipTextBox.Text.Trim().Replace("-", ""); bool tryZipCode = int.TryParse(zipcodeSanitized, out notUsing); if (!tryZipCode) { success = false; errorMessage = "Error: Zip code must be numerical!"; } if (zipcodeSanitized.Length != 5 && zipcodeSanitized.Length != 9) { success = false; errorMessage = "Error: Zip code must be five or nine digits!"; } patient.setZipcode(zipcodeSanitized); //check state formatting string stateSanitized = patientStateTextBox.Text.Trim(); if (stateSanitized.Length != 2) { success = false; errorMessage = "Error: Please use two digit state codes for states!"; } patient.setState(stateSanitized); patient.setFirstName(patientFirstNameTextBox.Text.Trim()); // make sure middle initial is one initial string middleInitial = PatientMiddleInitialTextBox.Text.Trim(); if (middleInitial.Length > 1) { success = false; errorMessage = "Error: Patient's middle initial must be one character!"; } else if (middleInitial.Length == 1) { patient.setMiddleInitial(middleInitial[0]); } patient.setLastName(patientLastNameTextBox.Text.Trim()); string gender = genderBox.Text.Trim(); if (gender.Length != 1) { success = false; errorMessage = "Error: Patient's gender must be one character!"; } else { patient.setGender(gender[0]); } if (comboDonorStatus.Text == "True") { patient.setOrganDonorStatus(true); } else if (comboDonorStatus.Text == "False") { patient.setOrganDonorStatus(false); } else { success = false; errorMessage = "Error: Please select a donor status!"; } if (comboDNR.Text == "True") { patient.setDoNotResuscitateStatus(true); } else if (comboDNR.Text == "False") { patient.setDoNotResuscitateStatus(false); } else { success = false; errorMessage = "Error: Please select a DNR status!"; } if (success) { createPatient(patient); // we have been successful, create the patient and leave this form } } catch (Exception ee) { errorMessage = ee.Message; success = false; } } if (!success) { string message = errorMessage; string caption = "Error!"; MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show(message, caption, buttons); } }
public UseInventory(RADGSHALibrary.Patient selectedPatient, RADGSHALibrary.Visit selectedVisit) { InitializeComponent(); this.selectedPatient = selectedPatient; this.selectedVisit = selectedVisit; }